--- tags: leetcode --- # [253. Meeting Rooms II](https://leetcode.com/problems/meeting-rooms-ii/) --- # My Solution ## The Key Idea for Solving This Coding Question ## C++ Code ```cpp= #define START (0) #define END (1) class cmp { public: bool operator()(int a, int b) { return a > b; } }; class Solution { public: int minMeetingRooms(vector<vector<int>> &intervals) { sort(intervals.begin(), intervals.end(), [](vector<int> &a, vector<int> &b){ return a[START] < b[START]; }); int rooms = 0; priority_queue<int, vector<int>, cmp> heap; for (auto &interval : intervals) { while (!heap.empty() && interval[START] >= heap.top()) { heap.pop(); } heap.push(interval[END]); if (rooms < heap.size()) { rooms = heap.size(); } } return rooms; } }; ``` ## Time Complexity ## Space Complexity # Miscellaneous <!-- # Test Cases ``` [[0,30],[5,10],[15,20]] ``` ``` [[7,10],[2,4]] ``` * Wrong Answer: ``` [[13,15],[1,13]] ``` * Wrong Answer: ``` [[9,10],[4,9],[4,17]] ``` * Wrong Answer: ``` [[5,8],[6,8]] ``` * Wrong Answer: ``` [[13,15],[1,13],[6,9]] ``` -->