1894. 找到需要补充粉笔的学生编号
为保证权益,题目请参考 1894. 找到需要补充粉笔的学生编号(From LeetCode).
解决方案1
Python
python
# 1894. 找到需要补充粉笔的学生编号
# https://leetcode-cn.com/problems/find-the-student-that-will-replace-the-chalk/
################################################################################
from typing import List
65
class Solution:
def chalkReplacer(self, chalk: List[int], k: int) -> int:
sums = sum(chalk)
k = k % sums
for i in range(len(chalk)):
k = k - chalk[i]
if k < 0:
return i
################################################################################
if __name__ == "__main__":
solution = Solution()
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22