Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '''
- sort both greed and cookies size, assign the smallest size cookie to a person which can satisfy the greed.
- '''
- class Solution:
- def findContentChildren(self, g: List[int], s: List[int]) -> int:
- g.sort()
- s.sort()
- ans=0
- i,j=0,0
- while j<len(s) and i<len(g):
- if g[i]<=s[j]:
- i+=1
- j+=1
- ans+=1
- else:
- j+=1
- return ans
Advertisement
Add Comment
Please, Sign In to add comment