We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e98fb5a commit 41c4f17Copy full SHA for 41c4f17
problems/0455.分发饼干.md
@@ -134,7 +134,21 @@ class Solution {
134
```
135
136
Python:
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
+```
152
153
Go:
154
0 commit comments