Intervals
Easy
Meeting Rooms
Determine if a person can attend all meetings.
10 min read
Solve on LeetCodeProblem Understanding
Given an array of meeting time intervals intervals where intervals[i] = [starti, endi], determine if a person can attend all meetings.
Example 1:
- Input:
[[0,30],[5,10],[15,20]] - Output:
false - Why? Meeting
[0,30]overlaps with both[5,10]and[15,20].
Example 2:
- Input:
[[7,10],[2,4]] - Output:
true
Algorithm Strategy
We simply need to check if any two intervals overlap. If we sort them by start time, we only need to check adjacent meetings.
- Sort: Sort intervals by
starttime. - Scan: Iterate through the sorted list.
- Check: If
current.start < previous.end, then there is an overlap. Returnfalseimmediately. - Result: If loop finishes without conflict, return
true.
Interactive Visualization
Step 1 / 1
Initializing...
1x
See the Logic in Motion
Stop memorizing code. Unlock the full interactive visualizer to master the logic step-by-step.ON THIS PAGE
- Problem Understanding
- Algorithm Strategy
- Interactive Visualization
- Dry Run
- Edge Cases & Common Mistakes
- Solution
Stop Guessing, Start Mastering.
Build the FAANG intuition. Master this pattern with optimized implementations, visual dry runs, and our curated collection of high-yield problems.
