# 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;
    }
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://timmybeeflin.gitbook.io/cracking-leetcode/array_problem/sweep-line/253.-meeting-rooms-ii.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
