def find_content_children(g,s):
g.sort(); s.sort(); i=j=0
while i<len(g) and j<len(s):
if s[j]>=g[i]: i+=1
j+=1
return i
public int findContentChildren(int[] g,int[] s){
Arrays.sort(g); Arrays.sort(s);
int i=0,j=0;
while(i<g.length&&j<s.length){
if(s[j]>=g[i]) i++;
j++;
} return i;
}
Greedy. sort() vs Arrays.sort().
def find_content_children(g,s):
g.sort(); s.sort(); i=j=0
while i<len(g) and j<len(s):
if s[j]>=g[i]: i+=1
j+=1
return i
public int findContentChildren(int[] g,int[] s){
Arrays.sort(g); Arrays.sort(s);
int i=0,j=0;
while(i<g.length&&j<s.length){
if(s[j]>=g[i]) i++;
j++;
} return i;
}
1. Sort both 2. Match smallest to smallest