```
public class Solution {
public boolean containsDuplicate(int[] nums) {
int n = nums.length;
HashMap<Integer, Integer> hashMap = new HashMap<Integer, Integer>();
for(int i = 0; i < n; i++){
if(hashMap.containsKey(nums[i])){
return true;
}else{
hashMap.put(nums[i], i);
}
}
return false;
}
}
```