Slice and splice solution?

  • 0

    Here's a solution that I believe should work. When I test each line of the code, it works, but then when I use the whole function it doesn't work.

    var rotate = function(nums, k) {
        var temp = nums.slice(0, k+1);
        nums.splice(0, k+1); 
        nums = nums.concat(temp);

    Anyone have any ideas about what's going on?

Log in to reply

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