Skip to content

Commit 2261b21

Browse files
author
jinvicky
committed
contains duplicate solution
1 parent 53ce7c7 commit 2261b21

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

contains-duplicate/jinvicky.java

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

0 commit comments

Comments
 (0)