Find the Student that Will Replace the Chalk LeetCode solution in Python

1
class Solution:
2
def chalkReplacer(self, chalk: List[int], k: int) -> int:
3
x = sum(chalk)
4
if x < k:
5
k = k % x
6
if x == k:
7
return 0
8
i = 0
9
n = len(chalk)
10
while True:
11
if chalk[i] <= k:
12
k -= chalk[i]
13
else:
14
break
15
i += 1
16

17
return i

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0