0
0

More than 1 year has passed since last update.

Leetcode 1894. Find the Student that Will Replace the Chalk

Posted at

1894. Find the Student that Will Replace the Chalk

例を確認して考えている通り実装

class Solution {
    public int chalkReplacer(int[] chalk, int k) {
        int index = 0;
        while (0 < k - chalk[index]) {
            k -= chalk[index];
            if (index < chalk.length - 1) {
                index++;
            } else {
                index = 0;
            }
        }
        return index;
    }
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0