6 sorting/17 meeting max guests/main.cpp
/*
Given arrival and departure timings find maximum number of people that we can meet
in the party once we go to party in a certain time interval
*/
Given arrival and departure timings find maximum number of people that we can meet
in the party once we go to party in a certain time interval
Given arrival and departure timings find maximum number of people that we can meet in the party once we go to party in a certain time interval
int efficient(int arrival[], int departure[], int n){ 
    sort(arrival, arrival+n);
    sort(departure, departure+n);
    int i=1,j=0,res=1,curr=1;
    while(i<n && j<n){
        if(arrival[i] <= departure[j]){
            curr++;
            i++;
        }
        else{
            curr--;
            j++;
        }
        res = max(res,curr);
    }
    return res;
}
int efficient ( int arrival [ ] , int departure [ ] , int n ) { sort ( arrival , arrival + n ) ; sort ( departure , departure + n ) ; int i = 1 , j = 0 , res = 1 , curr = 1 ; while ( i < n && j < n ) { if ( arrival [ i ] <= departure [ j ] ) { curr ++ ; i ++ ; } else { curr -- ; j ++ ; } res = max ( res , curr ) ; } return res ; }
Given arrival and departure timings find maximum number of people that we can meet
in the party once we go to party in a certain time interval
Given arrival and departure timings find maximum number of people that we can meet in the party once we go to party in a certain time interval
//O(nlogn)