Skip to content

1894. Find the Student that Will Replace the Chalk #459

Answered by topugit
mah-shamim asked this question in Q&A
Discussion options

You must be logged in to vote

Let's break down the problem step by step:

Approach:

  1. Total Chalk Consumption:
    First, calculate the total amount of chalk needed for one complete round (from student 0 to student n-1). This will help us reduce the value of k by taking into account how many complete rounds can be covered by k pieces of chalk.

  2. Reduce k by Modulo:
    If k is larger than the total chalk required for one complete round, we can simplify the problem by taking k % total_chalk. This operation will give us the remaining chalk after as many full rounds as possible, leaving us with a smaller problem to solve.

  3. Find the Student Who Runs Out of Chalk:
    Iterate through each student's chalk consumption, subtracting it from

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@mah-shamim
Comment options

mah-shamim Sep 2, 2024
Maintainer Author

@topugit
Comment options

topugit Sep 2, 2024
Collaborator

Answer selected by mah-shamim
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
question Further information is requested medium Difficulty
2 participants