Why it is wrong???


  • -3
    A

    public class Solution {
    public void rotate(int[] nums, int k) {
    if (nums.length<=1||k>nums.length) return;
    int[] ret = new int[nums.length];
    int j=0;
    for (int i=nums.length-k;i<nums.length;i++){
    ret[j++]=nums[i];
    }
    for (int m=0;m<nums.length-k;m++){
    ret[j++]=nums[m];
    }

    }
    

    }


Log in to reply
 

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