int removeDuplicates(vector<int>& nums) { set<int> s; for(int i=0;i<nums.size();++i) { s.insert(nums[i]); } set<int> :: iterator it; vector<int> v; for(it=s.begin();it!=s.end();++it) { v.push_back(*it); } nums=v; int a = s.size(); return a; }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter