Tap here to switch tabs
Problem
Submissions

Problem: Find the Student that Will Replace the Chalk

Try to solve the Find the Student that Will Replace the Chalk problem.

Statement

There are nn students numbered from 00 to n−1n - 1 sitting in a classroom, and an integer array chalk of length nn, where chalk[i] represents the number of pieces of chalk that student i consumes to solve a single problem. You are also given an integer k, representing the initial amount of chalk pieces.

The students take turns answering questions in order starting from student 00 up to student n−1n - 1. Once student n−1n - 1 completes their turn, the process restarts from student 00 and continues in this cyclic order.

During their turn, if the number of remaining chalk pieces is strictly less than chalk[i], student i must replace the chalk.

Return the index of the student who will replace the chalk.

Constraints:

  • chalk.length ==n== n

  • 1≤n≤1051 \leq n \leq 10^5

  • 1≤1 \leq chalk[i] ≤105\leq 10^5

  • 1≤k≤1091 \leq k \leq 10^9

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Find the Student that Will Replace the Chalk

Try to solve the Find the Student that Will Replace the Chalk problem.

Statement

There are nn students numbered from 00 to n−1n - 1 sitting in a classroom, and an integer array chalk of length nn, where chalk[i] represents the number of pieces of chalk that student i consumes to solve a single problem. You are also given an integer k, representing the initial amount of chalk pieces.

The students take turns answering questions in order starting from student 00 up to student n−1n - 1. Once student n−1n - 1 completes their turn, the process restarts from student 00 and continues in this cyclic order.

During their turn, if the number of remaining chalk pieces is strictly less than chalk[i], student i must replace the chalk.

Return the index of the student who will replace the chalk.

Constraints:

  • chalk.length ==n== n

  • 1≤n≤1051 \leq n \leq 10^5

  • 1≤1 \leq chalk[i] ≤105\leq 10^5

  • 1≤k≤1091 \leq k \leq 10^9