Blind 75 · #66 · Intervals

Meeting Rooms

EasySort + adjacent checkTime O(n log n)Space O(1) beyond sorting

Meeting Rooms is an easy Intervals problem from the Blind 75. The key pattern is sort + adjacent check, and a good solution runs in O(n log n) time.

Problem

Determine whether one person can attend every half-open meeting interval without overlap.

Examples

Example 1

Input

[[0,5],[5,9],[10,12]]

Output

true

Example 2

Input

[[0,20],[4,8],[12,16]]

Output

false

Example 3

Input

[[8,11],[3,5]]

Output

true

Approach

Sort meetings by start; one person can attend all of them unless some meeting starts before the previous one ends.

PatternSort + adjacent check
TimeO(n log n)
SpaceO(1) beyond sorting

Watch out for

Intervals are half-open: a meeting may start exactly when another ends.

More Intervals problems