Question:Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in the array, and it should return false if every element is distinct.
It's quite easy to think about a o(n^2), but is too waste of time..and cannot be accepted
class Solution {
public:
bool containsDuplicate(vector<int>& nums) {
/*too waste of time*/
/*
for(int i=0;i<=nums.size()-1;i++)
{
for(int j=i+1;j<=nums.size()-1;j++)
{
if(nums[i]^nums[j]==0)
return true;
}
}
return false;
*/
}
};
SO we think about hash map ....let