//知识点:哈希-STL-unordered_map
#include<iostream>
using namespace std;
#include<vector>
#include<unordered_map>
class Solution {
public:
bool containsDuplicate(vector<int>& nums) {
unordered_map<int, int> hashmap;
if (nums.size() == 0)
{
return false;
}
else
{
for (int num : nums)
{
hashmap[num]++;
if (hashmap[num] >= 2) return true;
}
}
return false;
}
};
void test01() {
vector<int> m_num;
m_num.push_back(1);
m_num.push_back(2);
m_num.push_back(3);
m_num.push_back(1);
Solution S;
bool jd = S.containsDuplicate(m_num);
cout << jd << endl;
}
int main()
{
test01();
system("pause");
return 0;
}