class Solution {
public:
    bool containsDuplicate(vector<int>& nums) {
        int length = nums.size();
        sort(nums.begin(),nums.end());//比较相等的数据可以先对数组进行排序
       
        for (int i =0;i<length-1 ;i++)
         {  if(nums[i]==nums[i+1])
              return true;
           
         }
        return false;
    }
};

相关文章:

  • 2021-10-27
  • 2021-08-16
  • 2021-09-17
  • 2021-08-04
  • 2021-10-24
  • 2022-01-24
  • 2021-08-01
猜你喜欢
  • 2021-09-21
  • 2021-07-09
  • 2022-02-11
相关资源
相似解决方案