Skip to content

Commit 6c06e22

Browse files
committed
contains-duplicate solution
1 parent f291ae8 commit 6c06e22

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

contains-duplicate/kimbro97.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> numSet = new HashSet<>();
6+
for (int i = 0; i < nums.length; i++) {
7+
8+
if (numSet.contains(nums[i])) {
9+
return true;
10+
}
11+
numSet.add(nums[i]);
12+
}
13+
return false;
14+
}
15+
}

0 commit comments

Comments
 (0)