What's wrong with my java code


  • 0
    T

    I submitted my code, but it says mine is wrong. I did a debug on eclipse, the result is right. Can anyone tell me what's wrong with this?

    Here is the message from Leetcode:
    Input:
    [1,2]
    1
    Output:
    [1,2]
    Expected:
    [2,1]

        public void rotate(int[] nums, int k) {
            int[] copy = new int[nums.length];
            for(int i=0; i<nums.length; i++)
            {
                copy[(i+k)%nums.length] = nums[i];
            }
            nums = copy;
        }
    

Log in to reply
 

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