My 0ms C solution.


  • 1
    I
    int removeElement(int* nums, int numsSize, int val) {
        if (!nums || numsSize == 0) {
            return 0;
        }
        int idx_fill = 0;
        int idx_search;
        for (idx_search = 0; idx_search < numsSize; ++idx_search) {
            if (nums[idx_search] != val) {
                nums[idx_fill++] = nums[idx_search];
            }
        }
        return idx_fill;
    }

  • 0
    L

    you can't remove the elements equal to "val", however the judge system is working.


  • 0
    I

    I do not get your point, can you make it more explicit? you may give an example.


Log in to reply
 

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