All Blind 75 questions

Meeting Rooms

FreeIntervalsEasy66 of 75

The problem

Given meeting intervals with start < end, determine whether one person can attend every meeting. A meeting ending when another begins is allowed.

Example

[[1, 4], [4, 6], [8, 9]] → true

Need a hint?

After sorting, only neighboring meetings need comparison.

Write pseudocode, trace the example, or note an edge case. This scratchpad does not run code.

Notes stay in this browser when storage is available.

Read the solution approach

Sort intervals by start. If any start is earlier than the previous interval’s end, return false. Otherwise return true. Empty and single-meeting schedules are conflict-free. Use a strict comparison so back-to-back meetings are accepted.

Complexity

O(n log n) time; sorting determines auxiliary space.

Before moving on, explain why the algorithm is correct and trace a boundary case without looking at the approach.