分发饼干
程序员文章站
2022-06-17 19:50:12
...
Python
class Solution(object):
def findContentChildren(self, g, s):
"""
:type g: List[int]
:type s: List[int]
:rtype: int
"""
g.sort()
s.sort()
count = 0
i, j = 0, 0
while i < len(g) and j < len(s):
while j < len(s) and s[j] < g[i]: count += 1
if j < len(s): count += 1
i += 1
j += 1
return count
上一篇: 二叉树题目汇总
下一篇: 算法笔记-快速排序之无序数组中查找中位数