Solution URL
https://leetcode.com/submissions/detail/420902405/
代码
class Solution {
public boolean containsDuplicate(int[] nums) {
//ans: Solution
//Time: O(N). for hashset, search and insert are contant time and these operation
//does for n times. So the O(N)
//Space: O(N)
HashSet<Integer> set = new HashSet<>();
for(int num: nums){
if(set.contains(num)) return true;
set.add(num);
}
return false;
}
}