Meeting Rooms

easyIntervalssort by start + adjacent overlap checkB75Solve on LeetCode#252

Part of Practice: Rooms & Queries

You are given a list of meeting time intervals, each a pair [start, end]. Decide whether one person could attend every meeting — that is, whether no two meetings overlap. Return true if the schedule is conflict-free, false otherwise. A meeting that starts exactly when another ends is fine: back-to-back is not a conflict.

Constraints that matter: up to 100,000 meetings in arbitrary order, so comparing every pair (O(n²)) is wasteful — sorting reduces the check to adjacent pairs only.

Examples

Input:
intervals = [[0,30],[5,10],[15,20]]
Output:
false

The meeting [0,30] is still running when [5,10] starts.

Input:
intervals = [[7,10],[2,4]]
Output:
true

Sorted, the meetings are [2,4] then [7,10]; the first ends before the second begins.

Input:
intervals = [[1,5],[5,8]]
Output:
true

Back-to-back meetings share only the instant 5, which is not a conflict.

Hints

One at a time — struggle first, peek second.

Your thinking space — verify on LeetCode, then mark it.