Leetcode_455_分发饼干_水题

12/25

虽然是水题,但我写了一堆bug,调了十几分钟QAQ
class Solution {
    
    
    public int findContentChildren(int[] g, int[] s) {
    
    
        int stg=0;
        int sts=0;
        Arrays.sort(g);
        Arrays.sort(s);
        while(stg<g.length&&sts<s.length){
    
    
            while(g[stg]>s[sts]) {
    
    
                if(++sts>=s.length){
    
    
                    return stg;
                }
            }
            sts++;
            stg++;
        }
        return stg;
    }
}

猜你喜欢

转载自blog.csdn.net/HDUCheater/article/details/111660332