标签:amp problem maps ons set contain == .com tor
class Solution { public: bool containsDuplicate(vector<int>& nums) { int length = nums.size(); if(length <= 0) return false; sort(nums.begin(),nums.end()); for(int i = 1;i < length;i++){ if(nums[i] == nums[i-1]) return true; } return false; } };
这个题有很多种做法:https://leetcode.com/problems/contains-duplicate/discuss/61110/C++-solutions-(sorting-maps-and-sets).
还有Contains Duplicate II Contains Duplicate III
leetcode 217. Contains Duplicate
标签:amp problem maps ons set contain == .com tor
原文地址:https://www.cnblogs.com/ymjyqsx/p/9651757.html