Skip to content

Commit 2f73f7a

Browse files
committed
Contains Duplicate Solution
1 parent 6690735 commit 2f73f7a

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

contains-duplicate/river20s.java

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

0 commit comments

Comments
 (0)