generate functionFri, 20 Jan 2023

You are given a set of time intervals. Each segment is set in the format HH:MM:SS-HH:MM:SS, that is, first the hours, minutes and seconds of the left border of the segment are set, and then the hours, minutes and seconds of the right border. You need to validate a given set of time intervals. In other words, you need to check the following conditions: the hours, minutes and seconds are set correctly (that is, the hours are in the range from 0 to 23, and the minutes and seconds are in the range from 0 to 59); the left boundary of the segment is no later than its right boundary (but the boundaries may be equal); no pair of segments intersect (even at boundary points in time). You need to output YES if a given set of time intervals passes validation, and NO otherwise.

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; using System.Globalization; using System.Collections; using System.IO; class Solution { static void Main(String[] args) { int N = int.Parse(Console.ReadLine()); var times = new ArrayList(); var intervals = new ArrayList(); int i = 0; while(i < N){ var time = Console.ReadLine(); if(!times.Contains(time)){ times.Add(time); } i++; } foreach(var time in times){ var interval = time.Split('-'); var left = interval[0]; var right = interval[1]; intervals.Add(new Interval(left, right)); } bool valid = true; for(int j = 0; j <

Questions about programming?Chat with your personal AI assistant