5. Rotate Array
Easy
Return a new array obtained by rotating nums to the right k positions. If k is greater than the size, the rotations repeat.
Example 1
Input: nums = [1,2,3,4,5], k = 2
Output: [4,5,1,2,3]
Example 2
Input: nums = [9,6,2], k = 3
Output: [9,6,2]
Constraints
- 0 <= nums.length <= 10000
- 0 <= k <= 100000
Arrays
Saved in this browser
Caso 1
nums =
[1,2,3,4,5]
k =
2
Expected =
[4,5,1,2,3]
Caso 2
nums =
[9,6,2]
k =
3
Expected =
[9,6,2]
Run checks these 2 cases. Submit runs all 6, including hidden ones.