There are `n` students numbered 0 to n - 1 who take turns solving problems in order, starting again from student 0 after student n - 1. Student `i` uses `chalk[i]` pieces of chalk per problem. You start with `k` pieces. When the chalk left is strictly less than what the current student needs, that student must replace the chalk. Return the index of that student.
There are n students numbered 0 to n - 1 who take turns solving problems in order, starting again from student 0 after student n - 1. Student i uses chalk[i] pieces of chalk per problem. You start with k pieces. When the chalk left is strictly less than what the current student needs, that student must replace the chalk. Return the index of that student.
Example 1:
Input: {"chalk":[5,1,5],"k":22}
Output: 0
Constraints:
chalk.length=n
1≤n≤105
1≤chalk[i]≤105
1≤k≤109
Test Cases
Input (Stdin)
Expected Output (Stdout)
Execution Result
Run code to see results.
Input
arr ={"chalk":[5,1,5],"k":22}
k = 22 pieces
one round = ?
0
5
1
1
2
5
one round of chalk, split by student (running totals below)
0
5
0
0
Student 0 uses 5 piece(s) per problem, so one turn of student 0 costs 5.