Leetcode in Java && Oracle
421 subscribers
8 photos
397 files
400 links
Second channel: @codeforces_java

Let's Develop Together!
Download Telegram
image_2021-12-10_00-33-29.png
38.1 KB
#N217. Contains Duplicate
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;

}
}