Skip to content

Commit

Permalink
217. Contains Duplicate
Browse files Browse the repository at this point in the history
Added solution for 217. Contains Duplicate
  • Loading branch information
IshanAryendu authored Apr 4, 2022
1 parent 933ca4a commit db8e059
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions java/217_Contains_Duplicate.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class Solution {
public boolean containsDuplicate(int[] nums) {
if(nums.length == 0) return false;
Set<Integer> set = new HashSet<>();
for(int num: nums){
if(set.contains(num)){
return true;
}
set.add(num);
}
return false;
}
}

0 comments on commit db8e059

Please sign in to comment.