> For the complete documentation index, see [llms.txt](https://timmybeeflin.gitbook.io/cracking-leetcode/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://timmybeeflin.gitbook.io/cracking-leetcode/array_problem/sweep-line/253.-meeting-rooms-ii.md).

# 253. Meeting Rooms II

T: O(nlogn)

S: O(n)

```java
class Solution {
    private static final int START = 1;
    private static final int END = -1;
    public int minMeetingRooms(int[][] intervals) {
        
        TreeMap<Integer, Integer> map = new TreeMap<>();
        for (int[] interval : intervals) {
            map.put(interval[0], map.getOrDefault(interval[0], 0) + START);
            map.put(interval[1], map.getOrDefault(interval[1], 0) + END);
        }
        
        int max = 0;
        int num = 0;
        for (int value : map.values()) {
            num += value;
            max = Math.max(max, num);
        }
        return max;
    }
}
```
