public class Solution {
public int findContentChildren(int[] g, int[] s) {
if(g == null || s == null || g.length == 0 || s.length == 0) {
return 0;
}
Arrays.sort(g);
Arrays.sort(s);
boolean[] fg = new boolean[s.length];
int count =0;
for(int i = g.length-1;i>=0&&count<s.length;i--) {
for(int j = s.length-1;j>=0;j--) {
if(!fg[j] && s[j]>=g[i]) {
fg[j] = true;
count++;
break;
}
}
}
return count;
}
}
455. Assign Cookies
最新推荐文章于 2021-03-21 15:18:25 发布