Skip to content

Commit 41c4f17

Browse files
committed
添加 0455.分发饼干 python3版本
1 parent e98fb5a commit 41c4f17

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

problems/0455.分发饼干.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,21 @@ class Solution {
134134
```
135135

136136
Python:
137-
137+
```python
138+
class Solution:
139+
def findContentChildren(self, g: List[int], s: List[int]) -> int:
140+
#先考虑胃口小的孩子
141+
g.sort()
142+
s.sort()
143+
i=j=0
144+
count = 0
145+
while(i<len(g) and j<len(s)):
146+
if g[i]<=s[j]:
147+
count+=1
148+
i+=1 #如果满足了,则继续遍历下一个孩子和下一块饼干
149+
j += 1 #如果最小的饼干没有满足当前最小胃口的孩子,则遍历下一块饼干
150+
return count
151+
```
138152

139153
Go:
140154

0 commit comments

Comments
 (0)