You are viewing a single comment's thread. Return to all comments →
Have you tried running this? You actually run into an issue where you just propagate the first value in the array across all other indices in the array using your method.
The second for loop moves the value at index 0, the 1, over to index 1, overwriting the value 2 at index 1, and then this 1 gets written into all the other indices as a result.