I don't know where is wrong.I want to ask for some help .


  • 0
    6
    1. Rotate Array
      when I submit my code.it is called memory corruption . I don't know why.
      void rotate(int* nums, int numsSize, int k)
      {
      if(k>numsSize)
      {
      k=k%numsSize;
      }
      int res=numsSize-k;
      if(k<=numsSize)
      {
      for(int i=numsSize;i>=k;i--)
      {
      nums[i]-=k;
      }
      for(int i=k-1;i>=0;i--)
      {
      nums[i]+=res;
      }
      }
      }

Log in to reply
 

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