1894. Find the Student that Will Replace the Chalk

Updated: 2024-03-12
1 min read
[]

On This Page

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