Shawngbk / Leecode

Questions of Leecode
0 stars 0 forks source link

455. Assign Cookies #158

Open Shawngbk opened 7 years ago

Shawngbk commented 7 years ago

public class Solution { public int findContentChildren(int[] g, int[] s) { Arrays.sort(g); Arrays.sort(s);

    int pointerG = 0, pointerS = 0;

    while(pointerG < g.length && pointerS < s.length) {
        if(g[pointerG] <= s[pointerS]) {
            pointerG++;
            pointerS++;
        } else {
            pointerS++;
        }
    }
    return pointerG;
}

}