class Solution:
def distributeCandies(self, candies: int, num_people: int) -> List[int]:
if not candies:
return []
res=[0]*num_people
j=1
while candies>0:
for i in range(num_people):
if candies>j:
res[i]+=j
else:
res[i]+=candies
candies=0
break
candies-=j
j+=1
return res
leetcode -1103. 分糖果 II(python)
猜你喜欢
转载自blog.csdn.net/qq_42738654/article/details/104684505
今日推荐
周排行