Your calendar for the day is the list intervals, where intervals[i] = [startᵢ, endᵢ] books a meeting from time startᵢ up to time endᵢ. You can only be in one meeting at a time.
Return true if you can go to every meeting, and false if any two of them clash. A meeting that ends at time t does not clash with one that starts at t: you can walk straight from one to the next.
The meeting from 11 to 15 starts while the one from 9 to 12 is still running.
In time order the meetings are [3,6], [6,8] and [13,16]. The second starts the moment the first ends, which is allowed.
[]
With nothing booked there is nothing to clash.
Constraints
0 <= intervals.length <= 10⁴intervals[i].length == 20 <= startᵢ < endᵢ <= 10⁶Two meetings clash when each one starts before the other ends. Sort the meetings by start time, and any clash shows up between two neighbours in that order.
First pin down what a clash is. Meeting A runs from A.start up to A.end, and the end itself is free: you can leave at 12 and start something else at 12. Two meetings share a moment exactly when each one starts before the other ends. If either one starts at or after the other's end, they don't touch.
Time O(n log n)Space O(n)
The full walkthrough and code are part of Premium
false