My c solution,T(n)=O(n),S(n)=O(1)


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

Log in to reply
 

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