Skip to content

Commit ff72247

Browse files
committed
Add contains-duplicate solution - s0ooo0k
1 parent 78edcfe commit ff72247

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

contains-duplicate/s0ooo0k.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/*
2+
* 시간복잡도 O(n)
3+
* 공간복잡도 O(n)
4+
*/
5+
class Solution {
6+
public boolean containsDuplicate(int[] nums) {
7+
Set<Integer> set = new HashSet<>();
8+
9+
for(int n : nums) {
10+
if(set.contains(n)){
11+
return true;
12+
}
13+
set.add(n);
14+
}
15+
return false;
16+
}
17+
}

0 commit comments

Comments
 (0)