Meeting Rooms
Problem
A person is invited to a set of meetings. Each meeting is a half-open time range [start, end); a meeting that ends at time t does not conflict with one that begins at t. Given the list intervals of all meetings, decide whether the person can attend every one of them, i.e. whether no two meetings overlap. Return True if they can, False otherwise.
- Up to around ten thousand meetings.
- Start and end times are non-negative and fit comfortably in a normal int, with
start < end.
Examples
[[3,20],[8,12],[22,25]]→False. The first meeting runs until 20 and the second starts at 8.[[9,12],[1,3]]→True. They are given out of order but do not overlap.[[2,6],[6,9]]→True. Ending at 6 and starting at 6 is allowed under half-open semantics.
Hints
- Comparing every pair is O(n²). If you sort by start time, which pairs could still possibly conflict?
- After sorting, a meeting conflicts with some earlier meeting only if it starts before the previous one ends. Why is the immediate predecessor enough?
- Sort by start, then a single pass checking
intervals[i].start < intervals[i-1].end.
Last reviewed 8 September 2026
Approach · Solution (Python) · Complexity · Follow-ups · Company variations · Tests
The rest of this question — the worked approach, the Python solution with passing tests, complexity, follow-ups and how each company frames it — is part of the guides.
Get the full guide
Pick the company you're interviewing with. Each guide has every question tiered for that loop — one-time purchase, lifetime access.
Also in: Apple, Google, Meta, Microsoft, Netflix
Interviewing at more than one? All 6 guides for $499 · save $395
Not ready to buy? Get the free starter pack — 13 questions with full solutions.