C++ Simplest 1-Line Using STL, O(N) Time O(1) Space


  • 0
    M
    class Solution {
    public:
        int removeElement(vector<int>& nums, int val) {
            return remove(nums.begin(), nums.end(), val) - nums.begin();
        }
    };
    

Log in to reply
 

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