https://leetcode.com/problems/assign-cookies/submissions/
1. 전체 코드
1-1. 그리디
class Solution:
def findContentChildren(self, g: List[int], s: List[int]) -> int:
g.sort()
s.sort()
g = deque(g)
s = deque(s)
ans = 0
while g and s:
cookie = s.popleft()
if cookie >= g[0]:
ans += 1
person = g.popleft()
return ans
2-2. 이진 탐색
class Solution:
def findContentChildren(self, g: List[int], s: List[int]) -> int:
g.sort()
s.sort()
result = 0
for i in s:
idx = bisect_right(g, i)
if idx > result:
result += 1
return result