2-line c++ solution using unique.


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

Log in to reply
 

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