my 0ms c solution


  • 0
    H
    int removeElement(int* nums, int numsSize, int val) {
        int sum=0;
        if(numsSize==0)
            return 0;
        for(int i=0;i<numsSize;i++)
        {
            if(nums[i]!=val)
            {
                int t=nums[sum];
                nums[sum]=nums[i];
                nums[i]=t;
                sum++;
            }
        }
        return sum;
    }
    

Log in to reply
 

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