leetcode 455. 分发饼干

image

class Solution {
    public int findContentChildren(int[] g, int[] s) {
        Arrays.sort(g);
        Arrays.sort(s);
        int ans=0;
        for(int i=0,j=0;i<g.length&&j<s.length;j++){
            if(g[i]<=s[j]){
                ans++;
                i++;
            }
        }
        return ans;
    }
}
posted @ 2022-02-19 13:08  livingsu  阅读(30)  评论(0)    收藏  举报