Simple Java Solution


  • 0
    E
    public class Solution {
        public int findContentChildren(int[] g, int[] s) {
            Arrays.sort(g);
            Arrays.sort(s);
            int x=0,sum=0;
            for(int i=0;i<g.length;i++){
                for(int j=x;j<s.length;j++){
                    if(g[i]<=s[j]){
                        x=j+1;
                        sum++;
                        break;
                    }
                }
            }
            return sum;
        }
    }
    

Log in to reply
 

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