• + 1 comment

    It's the same thing brother

    He is beginning from the second last index and decrementing progressively, copying the element at that index to the next index, which does the same as your approach - working from the last index through to the second index (which is 1) and copying the value at the preceeding index to the one the counter is at. Both methods perform a right rotation of the array elements from indices 1 to n-1, and both shall work if the value at the last index is stored in another variable and is copied to the first index after each rotation.