分发饼干
目录
分发饼干
https://leetcode-cn.com/problems/assign-cookies/
class Solution:
def findContentChildren(g, s) -> int:
= sorted(g)
g = sorted(s)
s = 0
n for i in range(len(s)):
if g[n] <= s[i]:
+= 1
n if n == len(g):
return n
return n
贪心算法的题目,考虑局部最优