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<vector<int>> arr(n,vector<int>(2,0));
- for(int i=0;i<n;i++)
- arr[i][0]=start[i],arr[i][1]=end[i];
- sort(arr.begin(),arr.end(),compare);
- int meeting=1,currTime=arr[0][1];
- for(int i=1;i<n;i++){
- if(arr[i][0]>currTime){
- meeting++;
- currTime=arr[i][1];
- }
- }
- return meeting;
- }
- static bool compare(vector<int> a,vector<int> b){
- return a[1]<b[1] || (a[1]==b[1] && a[0]<b[0]);
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement