I think my code is very simple in C++ but the runtime only beats 4.4%... eight lines


  • 0
    K
     int removeElement(vector<int>& nums, int val) {
        int point = 0;
        for(int i = 0; i < nums.size(); i++) {
            if(nums[i] != val)
                nums[point++] = nums[i];
        }
        return point;
    }
    

    what's the matter ? Hope for your help.


  • 3
    X

    beats 4.4%,but the other 95.6% are same to you ~~~ including me~~


Log in to reply
 

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