Problem
Given a list nums, rotate it to the right by `k` steps in place: each step moves the last element to the front. k may be larger than the length. As a follow-up, use O(1) extra space.
Example 1
- Input
- nums = [1, 2, 3, 4, 5, 6, 7], k = 3
- Output
- nums becomes [5, 6, 7, 1, 2, 3, 4]
Example 2
- Input
- nums = [-1, -100, 3, 99], k = 2
- Output
- nums becomes [3, 99, -1, -100]
The function returns nothing; the tests inspect nums after the call.
Constraints
1 <= nums.length <= 10^5-2^31 <= nums[i] <= 2^31 - 10 <= k <= 10^5