Advertisement
nikunjsoni

253

May 24th, 2021
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.50 KB | None | 0 0
  1. class Solution {
  2. public:
  3.     int minMeetingRooms(vector<vector<int>>& intervals) {
  4.         int res = 0;
  5.         sort(intervals.begin(), intervals.end());
  6.         priority_queue<int, vector<int>, greater<int>> pq;
  7.         for (auto& interval : intervals) {
  8.             while (!pq.empty()) {
  9.                 if (pq.top() > interval[0]) break;
  10.                 pq.pop();
  11.             }
  12.             pq.push(interval[1]);
  13.             res = max(res, int(pq.size()));
  14.         }
  15.         return res;
  16.     }
  17. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement