Find the Student that Will Replace the Chalk LeetCode solution in Java
1class Solution {23public int chalkReplacer(int[] chalk, int k) {4long sum = 0;5for (int c : chalk) {6sum += c;7}8long left = k % sum;9for (int i = 0; i < chalk.length; i++) {10if (left >= chalk[i]) {11left -= chalk[i];12} else {13return i;14}15}16return -1; // just for return statement, put whatever you want here17}18}