Share my clean java solution


  • 0
    C
    public int findContentChildren(int[] g, int[] s) {
    	int ret = 0;
        Arrays.sort(g);
        Arrays.sort(s);
        for(int gi = 0, si = 0; gi < g.length && si < s.length; si++){
        	 if(g[gi] <= s[si]){
        		ret++;
        		gi++;
        	}
        }
        return ret;
    }

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.