Updated codes using unordered_map, which can deal with negative integers:

```
class Solution {
public:
bool containsDuplicate(vector<int>& nums) {
unordered_map<int,int> hs;
int n = nums.size();
for(int i = 0; i < n; i++){
if(hs[nums[i]] == 0)
hs[nums[i]]++;
else if(hs[nums[i]] == 1)//If flag[key] = 1, then key already exists.
return true;
}
return false;
}
};
```

Following are the former code, which can only deal with positive numbers:

- If flag[key] = 1, then key already exists.

```
class Solution {
public:
bool containsDuplicate(vector<int>& nums) {
int flag[1000000] = {0};
int n = nums.size();
for(int i = 0; i < n; i++){
if(flag[nums[i]] == 0)
flag[nums[i]]++;
else if(flag[nums[i]] == 1)
return true;
}
return false;
}
};
```