image_2021-12-10_00-33-29.png
38.1 KB
#N217. Contains Duplicate
problem link
#solution
problem link
#solution
class Solution {
public boolean containsDuplicate(int[] nums) {
if(nums == null){
return false;
}
int len = nums.length;
HashSet<Integer> set = new HashSet<Integer>();
for(int i = 0; i < len; i++){
if(!set.add(nums[i])){
return true;
}
}
return false;
}
}