Share my 2-line c++ code


  • 0
    L


    class Solution {
    public:

        int removeDuplicates(vector<int>& nums) {
            nums.resize(distance(nums.begin(),unique(nums.begin(),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.