189. Rotate Array
Practice Rotate Array for free on NudgeCode: Medium, Two Pointers pattern. Write it in Python or JavaScript, run the tests in your browser, and ask for a hint when you are stuck.
Rotate nums to the right by k steps: each element moves k positions right, wrapping around to the front. Modify the array in place; don't return anything.
Example
nums = [1,2,3,4,5,6,7], k = 3 -> [5,6,7,1,2,3,4]
Constraints
- 1 <= nums.length <= 10^5
- 0 <= k <= 10^5 (
kmay be larger than the array length)