C++11 without loops


  • 0
    X
    class Solution {
    public:
        int removeDuplicates(vector<int>& nums) {
            nums.erase( unique( nums.begin(), nums.end() ), nums.end() );
            return nums.size();
        }
    };
    
    

    notice leetcode automatically includes <algorithm>


Log in to reply
 

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