217. 存在重复元素

 1 class Solution 
 2 {
 3 public:
 4     bool containsDuplicate(vector<int>& nums) 
 5     {
 6         unordered_map<int,int> hash;
 7         for(auto a : nums)
 8         {
 9             if(++ hash[a] == 2) return true;
10         }
11         return false;
12     }
13 };

 

posted @ 2020-04-10 16:17  Jinxiaobo0509  阅读(64)  评论(0)    收藏  举报