| 1 | // maths |
| 2 | class Solution { |
| 3 | public int chalkReplacer(int[] chalk, int k) { |
| 4 | long sum=0; |
| 5 | for(int i=0;i<chalk.length;i++){ |
| 6 | sum+=chalk[i]; |
| 7 | } |
| 8 | int remainingChalks = (int)(k % sum); |
| 9 | for(int i=0;i<chalk.length;i++){ |
| 10 | if(remainingChalks < chalk[i]){ |
| 11 | return i; |
| 12 | } |
| 13 | remainingChalks -= chalk[i]; |
| 14 | } |
| 15 | return -1; |
| 16 | } |
| 17 | } |
| 18 | |
| 19 | // binary search |
| 20 | class Solution { |
nothing calls this directly
no outgoing calls
no test coverage detected