Beats 100%


  • 1
    T
    class Solution {
    public:
        int removeElement(vector<int>& nums, int val) {
            int size = nums.size();
            int j = -1;
            for(int i = 0; i < nums.size(); i ++)
            {
                if(nums[i] != val)
                {
                    j ++;
                    nums[j] = nums[i];
                }
            }
    
            return j + 1;
        }
    };
    

Log in to reply
 

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