Skip to content

Commit 1d40150

Browse files
authored
Merge pull request #1143 from itsChrisJang/main
[itschrisjang] WEEK 01 solutions
2 parents fc5da12 + fb3d9e1 commit 1d40150

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

contains-duplicate/itschrisjang.java

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

0 commit comments

Comments
 (0)