Attend every meeting
Each meeting is a pair [start, end]: it begins at minute start and is over at minute end. The list intervals holds one person's meetings, in no particular order. Can that person sit through every meeting from start to end? Return True if no two meetings overlap, and False if any two do.
Two meetings overlap when each one starts before the other ends, so they share some time. A meeting may start at the exact minute another ends: [1, 3] and [3, 5] do not overlap.
intervals = [[9, 10], [1, 4], [5, 8]]OutputTrueIn time order they run 1 to 4, 5 to 8, 9 to 10. Each one ends before the next begins.
intervals = [[6, 9], [1, 3], [2, 5]]OutputFalse[2, 5] starts at minute 2, before [1, 3] ends at minute 3.
intervals = [[3, 5], [1, 3]]OutputTrueOne ends at minute 3 and the other starts at minute 3. Touching is not overlapping.
0 ≤ len(intervals) ≤ 105
0 ≤ start < end ≤ 106
Plan it first
Write a line for each before you code, then say them out loud. Compare with the Approach tab afterwards.