C++ solution


  • 0
    B

    class Solution {
    public:
    int removeElement(vector<int>& nums, int val) {
    for(vector<int>::iterator iter = nums.begin(); iter!=nums.end();){
    if(*iter==val){
    iter = nums.erase(iter);
    }
    else
    iter++;
    }
    return nums.size();
    }
    };


Log in to reply
 

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