Skip to content

Commit f6d8e29

Browse files
committed
Time: 315 ms (8.63%), Space: 19.5 MB (8.91%) - LeetHub
1 parent bf20089 commit f6d8e29

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from typing import List
2+
3+
4+
class Solution:
5+
def findContentChildren(self, greedyChildren: List[int], cookiesSize: List[int]) -> int:
6+
greedyChildren.sort()
7+
cookiesSize.sort()
8+
cookieIdx = 0
9+
childrenIdx = 0
10+
while cookieIdx < len(cookiesSize) and childrenIdx < len(greedyChildren):
11+
if cookiesSize[cookieIdx] >= greedyChildren[childrenIdx]:
12+
childrenIdx += 1
13+
cookieIdx += 1
14+
return childrenIdx
15+
16+
17+
greedyChildren = [1, 2, 3]
18+
cookiesSize = [1, 1]
19+
print(Solution().findContentChildren(greedyChildren, cookiesSize))

0 commit comments

Comments
 (0)