Skip to content

Commit 3568b91

Browse files
committed
solve contains duplicate problem
1 parent d50f125 commit 3568b91

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

contains-duplicate/sora0319.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,21 @@
11
import java.util.*;
2+
// 개선 방향
3+
class Solution {
4+
public boolean containsDuplicate(int[] nums) {
5+
Set duplication = new HashSet<>();
6+
7+
for(int n : nums){
8+
if(duplication.contains(n)){
9+
return true;
10+
}
11+
duplication.add(n);
12+
}
13+
return false;
14+
}
15+
}
16+
17+
18+
// 초기 문제 풀이
219
class Solution {
320
public boolean containsDuplicate(int[] nums) {
421
Arrays.sort(nums);

0 commit comments

Comments
 (0)