Doesn't work on LeetCode but works on my unit tests


  • 1
    S
    if(k > n)
    	k = k % n;
    int tmps[n - k];
    memcpy(tmps, nums, sizeof(tmps));
    memcpy(nums, &nums[n - k], sizeof(int)*(k));
    memcpy(&nums[k], tmps, sizeof(tmps));
    
    for(int i = 0; i < n; i++)
    	cout << nums[i] << " ";
    

    Running LeetCode_tests
    2 3 1 ..
    OK (2 tests, 2 ran, 2 checks, 0 ignored, 0 filtered out, 0 ms)

    But LeetCode always reports failure on [1,2,3],2 test case, say result is [3,3,1] not [2,3,1]


Log in to reply
 

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