class Solution {
public int findContentChildren(int[] g, int[] s) {
if(g==null||s==null) return 0;
Arrays.sort(g);
Arrays.sort(s);
int i=0,j=0;
while(i<g.length&&j<s.length){
if(g[i]<=s[j]){
i++;
}
j++;
}
return i;
}
}
class Solution {
public int eraseOverlapIntervals(int[][] intervals) {
if(intervals==null||intervals.length<=1) return 0;
Arrays.sort(intervals,(x,y)->(x[1]-y[1]));
int end=intervals[0][1],cnt=0;
for(int i=1;i<intervals.length;i++){
if(intervals[i][0]<end){
cnt++;
}
else{
end=intervals[i][1];
}
}
return cnt;
}
}
class Solution {
public int findMinArrowShots(int[][] points) {
if(points==null||points.length==0) return 0;
Arrays.sort(points,(x,y)->(x[1]-y[1]));
int cnt=1;
int end=points[0][1];
for(int i=1;i<points.length;i++){
if(points[i][0]>end){
cnt++;
end=points[i][1];
}
}
return cnt;
}
}