4ms C++ solution


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

Log in to reply
 

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