class Solution {
public int findContentChildren(int[] g, int[] s) {
Arrays.sort(g);
Arrays.sort(s);
int index = 0;
int count = 0;
for(int i = 0;i<s.length && index < g.length ;i++){
if(s[i] >= g[index]){
index++;
count++;
}
}
return count;
}
}
代码随想录——455. 分发饼干
最新推荐文章于 2024-10-01 18:51:18 发布