Skip to content

Commit

Permalink
2020-03-05
Browse files Browse the repository at this point in the history
  • Loading branch information
JiayangWu committed Mar 5, 2020
1 parent 4f70832 commit 427304c
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions 1103.分糖果II/1103-分糖果II.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
class Solution(object):
def distributeCandies(self, candies, num_people):
"""
:type candies: int
:type num_people: int
:rtype: List[int]
"""
res = [0 for _ in range(num_people)]
cnt = 1
while candies:
for i in range(num_people):
if candies >= cnt:
res[i] += cnt
candies -= cnt
cnt += 1
else:
res[i] += candies
candies = 0
break
return res

0 comments on commit 427304c

Please sign in to comment.