添加 0455.分发饼干 python3版本

This commit is contained in:
evanlai
2021-06-02 23:39:59 +08:00
parent e98fb5a56f
commit 41c4f17833

View File

@ -134,7 +134,21 @@ class Solution {
```
Python
```python
class Solution:
def findContentChildren(self, g: List[int], s: List[int]) -> int:
#先考虑胃口小的孩子
g.sort()
s.sort()
i=j=0
count = 0
while(i<len(g) and j<len(s)):
if g[i]<=s[j]:
count+=1
i+=1 #如果满足了,则继续遍历下一个孩子和下一块饼干
j += 1 #如果最小的饼干没有满足当前最小胃口的孩子,则遍历下一块饼干
return count
```
Go