Meeting Rooms - Problem
Given an array of meeting time intervals where intervals[i] = [starti, endi], determine if a person could attend all meetings.
A person can attend all meetings if no two meetings overlap. Two meetings overlap if one starts before the other ends.
Example: If you have meetings [[0,30], [5,10], [15,20]], you cannot attend all meetings because the first meeting [0,30] overlaps with both [5,10] and [15,20].
Input & Output
Example 1 — Overlapping Meetings
$
Input:
intervals = [[0,30],[5,10],[15,20]]
›
Output:
false
💡 Note:
The first meeting [0,30] overlaps with both [5,10] and [15,20]. Since meeting [0,30] runs from time 0 to 30, it conflicts with meeting [5,10] which starts at time 5 (before 30 ends).
Example 2 — Non-overlapping Meetings
$
Input:
intervals = [[7,10],[2,4]]
›
Output:
true
💡 Note:
After sorting by start time: [2,4] then [7,10]. Meeting [2,4] ends at time 4, and [7,10] starts at time 7. Since 4 < 7, there's no overlap.
Example 3 — Adjacent Meetings
$
Input:
intervals = [[1,3],[3,6],[6,8]]
›
Output:
true
💡 Note:
Meetings end exactly when the next one starts: [1,3] ends at 3, [3,6] starts at 3. This is allowed - meetings can be back-to-back without overlap.
Constraints
- 0 ≤ intervals.length ≤ 104
- intervals[i].length == 2
- 0 ≤ starti < endi ≤ 106
Visualization
Tap to expand
Understanding the Visualization
1
Input
Array of meeting intervals with start and end times
2
Process
Check if any meetings overlap in time
3
Output
Return true if all meetings can be attended, false otherwise
Key Takeaway
🎯 Key Insight: Sort meetings by start time, then only adjacent meetings can overlap
💡
Explanation
AI Ready
💡 Suggestion
Tab
to accept
Esc
to dismiss
// Output will appear here after running code