MEDIUM NC#134 Blind #39 Intervals
253. Meeting Rooms II
๐ Problem
Given an array of meeting time intervals intervals where intervals[i] = [start_i, end_i], return the minimum number of conference rooms required.
๐ง Visual Learning Aid
1 Model the input into the right structure
2 Choose the core technique and invariant
3 Execute step-by-step with a sample
4 Validate complexity and edge cases
JS/TS Refreshers
- โขArray methods (`push`, `pop`, `shift`, `slice`)
- โขObject/Map/Set usage patterns
- โขFunction parameter and return typing
Logical Thinking Concepts
- โขDefine invariants before coding
- โขCheck edge cases first (`[]`, single element, duplicates)
- โขEstimate time/space before implementation
๐ก Approach
- โ Sort start and end times separately
- โ When meeting starts, need a room
- โ When meeting ends, free up a room
- โ Track max rooms needed at any point
- โ Time: O(n log n), Space: O(n)
๐งญ Prerequisites
๐ ๏ธ Hints & Pitfalls
Hints
- โขSort start and end times separately
- โขWhen meeting starts, need a room
- โขWhen meeting ends, free up a room
Common Pitfalls
- โขTrack max rooms needed at any point
- โขTime: O(n log n), Space: O(n)
๐งช Test Cases
Hidden tests on submit: 1
Test Case 1
Not run Input:
minMeetingRooms([[0,30],[5,10],[15,20]]); Expected:
2 Test Case 2
Not run Input:
minMeetingRooms([[7,10],[2,4]]); Expected:
1 Test Case 3
Not run Input:
minMeetingRooms([[1,2],[2,3],[3,4]]); Expected:
1 ๐ Code Editor
๐ค Output