Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution
- {
- public:
- //Function to find the maximum number of meetings that can
- //be performed in a meeting room.
- int maxMeetings(int start[], int end[], int n)
- {
- vector <pair<int,int>> vec;
- for(int i = 0 ; i < n; i++){
- vec.push_back({start[i],end[i]});
- }
- auto comp = [](pair<int,int> a, pair<int,int> b){
- if(a.second != b.second)
- return(a.second < b.second);
- return(a.first < b.first);
- };
- sort(vec.begin(), vec.end(), comp);
- int en = -1;
- int ctr = 0;
- for(int i = 0; i < n; i++){
- if(vec[i].first > en){
- ctr++;
- en = vec[i].second;
- }
- }
- return ctr;
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement