Any one can help,passed in VS but failed in OJ?Runtime error


  • 0
    Z

    class Solution {
    public:
    void rotate(int nums[], int n, int k) {
    if(k>0&&n>0){
    int temp=0;
    temp=nums[(n-k)%n];
    for(int i=2;i<=n;i++)
    {
    nums[(i-1)(n-k)%n]=nums[i(n-k)%n];
    }
    nums[0]=temp;
    }
    }
    };


Log in to reply
 

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