Meeting Rooms
Easy · Intervals
You are given a list of meeting time intervals, each described by a start and end time. Determine whether a single person could attend every meeting without any two of them overlapping in time. Two meetings that only touch at a shared boundary (one ends exactly when the other starts) do not count as overlapping. Return true if all meetings can be attended, false otherwise.
Examples
Input: intervals = [[0,30],[5,10],[15,20]]
Output: false
Why: The meeting [0,30] overlaps with both [5,10] and [15,20], so one person cannot attend all of them.
Input: intervals = [[7,10],[2,4]]
Output: true
Why: The two meetings do not share any time, so a person can attend both.
Input: intervals = [[1,5],[5,8]]
Output: true
Why: The meetings touch exactly at time 5 but never actually overlap, so both can be attended.
Constraints
0 <= intervals.length <= 10^4, 0 <= starti < endi <= 10^9
Practise it by voice
Describe the solution out loud and the interviewer writes exactly what you say, asks when you are vague, and runs the tests in your browser.
This statement is written for CodeSpeek. The problem is part of the NeetCode 150 list; Watch NeetCode's explanation of Meeting Rooms. Reference solutions from the NeetCode repository (MIT) are used to verify our tests.