leetCode题解之Contains Duplicate

1、题目描述

2、题目分析

  直接使用hashTable 计数,超过1 则返回true,最后返回 false即可。

3、代码

  

 1  bool containsDuplicate(vector<int>& nums) {
 2         if( nums.size() == 0)
 3             return false;
 4         
 5         map<int,int> m;
 6         for( int i : nums)
 7             if( ++m[i] > 1)
 8                 return true;
 9         return false;
10     }
pp
原文地址:https://www.cnblogs.com/wangxiaoyong/p/8929758.html