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;
}
}
转载请注明原文地址: https://ju.6miu.com/read-26220.html