Given an integer array nums, rotate the array to the right by k steps, where k is non-negative. Must be done in-place with O(1) extra space.
nums = [1,2,3,4,5,6,7], k = 3[5,6,7,1,2,3,4]Rotating right by k is equivalent to bringing the last k elements to the front. Reversing all elements flips the order. Reversing the first k elements fixes the "last k" portion into sorted order. Reversing the remaining n−k elements fixes the "first n−k" portion. Three in-place reversals = one rotation.