The array is sorted, traversing, if sufficient to meet the child gi ++, but no matter how si has been a plus.
class Solution { public int findContentChildren(int[] g, int[] s) { Arrays.sort(g); Arrays.sort(s); int gi=0,si=0; while(gi<g.length&&si<s.length){ if(g[gi]<=s[si]) gi++; si++; } return gi; } }