Rotate Array
Write the code, see it run, pass the checks.
The problem
- medium
- Code
- Pro
Write rotate(nums, k): rotate the array nums k places to the right, so the last k numbers move to the front in the same order. k is a whole number, 0 or more, and may be larger than the length of nums. Change nums itself, in place, and return nothing; an empty array stays empty. For example, after rotate(nums, 3) with nums = [1, 2, 3, 4, 5, 6, 7], nums is [5, 6, 7, 1, 2, 3, 4].
Your code must pass
- Rotates the numbers k places to the right
- Handles k of 0 or larger than the length
- Changes the array in place and returns nothing
- Handles an empty array