Here is the complete solution:
function findContentChildren(greed, cookies)
sort greed in ascending order
sort cookies in ascending order
child := 0
cookie := 0
while child < length of greed and cookie < length of cookies
if cookies[cookie] >= greed[child] then
child := child + 1
cookie := cookie + 1
return child
Time: for sorting. Space: extra (or if sorting creates copies).