You are viewing a single comment's thread. Return to all comments →
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.
Seems like cookies are disabled on this browser, please enable them to open this website
Circular Array Rotation
You are viewing a single comment's thread. Return to all comments →
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.