-
-
Notifications
You must be signed in to change notification settings - Fork 298
/
Copy path455.py
38 lines (37 loc) · 1.15 KB
/
455.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
__________________________________________________________________________________________________
sample 180 ms submission
class Solution:
def findContentChildren(self, g: List[int], s: List[int]) -> int:
s.sort()#candy
g.sort()#kid
count=0
j=0#kid
for candy in s:
if j>len(g)-1:
return count
if g[j] <= candy:
count+=1
j+=1
return count
__________________________________________________________________________________________________
sample 14260 kb submission
#
# @lc app=leetcode id=455 lang=python3
#
# [455] Assign Cookies
#
class Solution:
def findContentChildren(self, g: List[int], s: List[int]) -> int:
satis = 0
g.sort()
s.sort()
for c in g:
i = 0
while i < len(s):
if c <= s[i]:
del s[i]
satis += 1
break
i += 1
return satis
__________________________________________________________________________________________________