Skip to content

Commit 894505b

Browse files
committed
feat:contains-duplicate solution
1 parent f291ae8 commit 894505b

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

contains-duplicate/sm9171.java

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

0 commit comments

Comments
 (0)