1894. Find the Student that Will Replace the Chalk

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

Содержание

LeetCode problem 1894

class Solution:
    def chalkReplacer(self, chalk: List[int], k: int) -> int:
        s = sum(chalk)
        k %= s
        for i, x in enumerate(chalk):
            if k < x:
                return i
            k -= x