Skip to content

Commit a3d7b57

Browse files
committed
contains duplicate solution
1 parent 53ce7c7 commit a3d7b57

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

contains-duplicate/leebeanbin.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import java.util.HashSet;
2+
3+
class Solution {
4+
public boolean containsDuplicate(int[] nums) {
5+
HashSet<Integer> arr = new HashSet<Integer>();
6+
boolean answer = false;
7+
8+
for(int num : nums){
9+
arr.add(num);
10+
}
11+
12+
if(nums.length != arr.size()){
13+
answer = true;
14+
}
15+
16+
return answer;
17+
}
18+
}

0 commit comments

Comments
 (0)