My simple solution in JavaScript


  • 0
    I
    /**
     * @param {number[]} nums
     * @param {number} k
     * @return {void} Do not return anything, modify nums in-place instead.
     */
    var rotate = function(nums, k) {
        while (k > 0) {
            nums.unshift(nums.pop());
            k--;
        }
    };
    
    

Log in to reply
 

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