My C++ solution by using erase. Fast can clean.


  • 0
    M
    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.