Skip to content

Commit 3ae9ff7

Browse files
committed
feat: contains duplicate
1 parent 8901b1d commit 3ae9ff7

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

contains-duplicate/minji-go.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+
import java.util.Set;
3+
4+
class Solution {
5+
public boolean containsDuplicate(int[] nums) {
6+
Set<Integer> count = new HashSet<>();
7+
boolean answer = false;
8+
for(int num : nums){
9+
if(count.contains(num)) {
10+
answer = true;
11+
break;
12+
}
13+
count.add(num);
14+
}
15+
return answer;
16+
}
17+
}

0 commit comments

Comments
 (0)