C in 11ms ,i use 2 for


  • 0
    X
    void rotate(int nums[], int n, int k) {
    

    int numr[n];
    int i;
    for(i=0;i<n;i++)
    numr[(i+k)%n]=nums[i];
    for(i=0;i<n;i++)
    nums[i]=numr[i];
    return nums[n];
    }


Log in to reply
 

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