You are viewing a single comment's thread. Return to all comments →
Could you possibly explain, or point to another resource, where I can better understand what is going on with (i+k)%n
The element at the i th position moves right k times: (i+k)
When we reach the last index of the array we need to go back to first index and that is what we are doing with %n.
You can have a better understanding by appliying the algorithm on the sample input.