• + 0 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.