xxxxxxxxxx
class pair{
int x;
int y;
pair(int x1,int y1){
x=x1;
y=y1;
}
}
class Solution
{
//Function to find the maximum number of activities that can
//be performed by a single person.
public static int activitySelection(int start[], int end[], int n)
{
pair p[]=new pair[n];
for(int i=0;i<n;i++){
pair it=new pair(start[i],end[i]);
p[i]=it;
}
Arrays.sort(p,(a,b)->a.y-b.y);
int i=0;int c=1;
for(int j=1;j<n;j++){
if(p[j].x>p[i].y){
i=j;
c++;
}
}
return c;
}
}