Warning: format not a string literal and no format arguments [-Wformat-security]


  • 0
    S
    void reverse(int *nums, int begin, int end){
        int temp;
        while(begin< end){
            temp =nums[begin];
            nums[begin++] = nums[end];
            nums[end--] = temp;
    }
    
    void rotate(int* nums, int numsSize, int k) {
        k = k% numsSize;
        if(k){
            reverse(nums, 0, numsSize-1);
            reverse(nums, 0, k-1);
            reverse(nums, k, numsSize-1);
        }
    }

Log in to reply
 

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