classSolution { public: boolcontainsDuplicate(vector<int>&nums) { sort(nums.begin(), nums.end()); intn=nums.size(); for (inti=0; i<n-1; i++) { if (nums[i] ==nums[i+1]) { returntrue; } } returnfalse; } };
classSolution { public: boolcontainsDuplicate(vector<int>&nums) { sort(nums.begin(), nums.end()); intn=nums.size(); for (inti=0; i<n-1; i++) { if (nums[i] ==nums[i+1]) { returntrue; } } returnfalse; } };