class Solution:
def findContentChildren(self, g: List[int], s: List[int]) -> int:
g.sort()
s.sort()
M, N = len(g), len(s)
i, j = 0, 0
while i < M and j < N:
if g[i] <= s[j]:
i += 1
j += 1
return i
class Solution:
def findContentChildren(self, g: List[int], s: List[int]) -> int:
heapq.heapify(g)
heapq.heapify(s)
answer = 0
while g and s:
i, j = heapq.heappop(g), heapq.heappop(s)
if i <= j:
answer += 1
else:
heapq.heappush(g, i)
return answer
or
class Solution:
def findContentChildren(self, g: List[int], s: List[int]) -> int:
heapq.heapify(g)
heapq.heapify(s)
answer = 0
while g and s:
if g[0] <= s[0]:
heapq.heappop(g)
answer += 1
heapq.heappop(s)
return answer