โ† All coding problems

Rotate an array

MediumArrays

Return a new array with nums rotated to the right by k steps. k can be larger than the length.

Function
function solve(nums, k)
Example 1
nums = [1,2,3,4,5]
k = 2
โ†’ [4,5,1,2,3]

Submit also runs 3 hidden tests, including edge cases.

console.log output is shown below