Given an integer array nums, rotate the array to the right by k steps, where k is non-negative.
Example 1
Input: nums = [1,2,3,4,5,6,7], k = 3
Output: [5,6,7,1,2,3,4]
Explanation: Rotating right by 3 moves the last 3 elements [5,6,7] to the front, and the rest shift right.
Example 2
Input: nums = [-1,-100,3,99], k = 2
Output: [3,99,-1,-100]
Explanation: Rotating right by 2 moves the last 2 elements [3,99] to the front, followed by [-1,-100].
Example 3
Input: nums = [1], k = 0
Output: [1]
Explanation: Rotating by 0 steps leaves the array unchanged.
Rotating right by k means the last k elements jump to the front. Reverse the whole array, then reverse the first k and the remaining n-k separately, and everything lands in the right place — all in O(1) extra space.
Run checks all cases above. Submit evaluates all test cases.