Simple Javascript Solution


  • 0
    R
    var rotate = function(nums, k) {
        for (let i=0;i<k;i++){
            nums.unshift(nums.pop())
        }
    };
    

    the compiler asks us not to return an array, otherwise we would

    return nums;
    

    after the for loop


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.