1103. Distribute Candies to People

Обновлено: 2024-03-12
1 мин
[]

Содержание

LeetCode problem 1103

class Solution:
    def distributeCandies(self, candies: int, num_people: int) -> List[int]:
        res = [0] * num_people
        i = 0
        while candies:
            res[i % num_people] += min(candies, i + 1)
            candies -= min(candies, i + 1)
            i += 1
        return res