【力扣】217.存在重复元素

class Solution {
public:
bool containsDuplicate(vector& nums) {
unordered_map hash;//定义hash表
for(int i=0;i hash[nums[i]]++;
}
for(int i=0;i if(hash[nums[i]]>1){
return true;
}
}
return false;
}
};

你可能感兴趣的:(力扣,c++)