Shear my C++ code


  • 0
    O
    class Solution {
    public:
        int removeElement(vector<int>& nums, int val) {
            int L=nums.size();
            for(int i=0;i<L;i++){
                if(nums[i]==val){
                    nums.erase(nums.begin()+i);
                    L--;
                    i--;
                }
            }
            return nums.size();
            
        }
    };

Log in to reply
 

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