标签:and empty require conf tar div str art struct
Given an array of meeting time intervals consisting of start and end times [[s1,e1],[s2,e2],...]
(si < ei), find the minimum number of conference rooms required.
For example,
Given [[0, 30],[5, 10],[15, 20]]
,
return 2
.
/** * Definition for an interval. * struct Interval { * int start; * int end; * Interval() : start(0), end(0) {} * Interval(int s, int e) : start(s), end(e) {} * }; */ class Solution { public: int minMeetingRooms(vector<Interval>& intervals) { sort(intervals.begin(),intervals.end(),[](Interval a,Interval b){return a.start<b.start;}); priority_queue<int,vector<int>, greater<int>> pq; int res=0; for(auto interval:intervals) { while(!pq.empty()&&interval.start>=pq.top()) pq.pop(); pq.push(interval.end); int size = pq.size(); res = max(res,size); } return res; } };
标签:and empty require conf tar div str art struct
原文地址:http://www.cnblogs.com/jxr041100/p/7885690.html