Skip to content

Commit 427304c

Browse files
committed
2020-03-05
1 parent 4f70832 commit 427304c

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

1103.分糖果II/1103-分糖果II.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
class Solution(object):
2+
def distributeCandies(self, candies, num_people):
3+
"""
4+
:type candies: int
5+
:type num_people: int
6+
:rtype: List[int]
7+
"""
8+
res = [0 for _ in range(num_people)]
9+
cnt = 1
10+
while candies:
11+
for i in range(num_people):
12+
if candies >= cnt:
13+
res[i] += cnt
14+
candies -= cnt
15+
cnt += 1
16+
else:
17+
res[i] += candies
18+
candies = 0
19+
break
20+
return res

0 commit comments

Comments
 (0)