Skip to content

Commit eb9f6ce

Browse files
committed
contains-duplicate solution
1 parent 53ce7c7 commit eb9f6ce

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
.vscode/
33
.DS_Store
44
.env
5+
/leetcode-study.iml

contains-duplicate/shinheekim.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+
import java.util.Set;
3+
4+
class Solution {
5+
public boolean containsDuplicate(int[] nums) {
6+
Set<Integer> visited = new HashSet<>();
7+
8+
for (int n : nums){
9+
if (!visited.add(n)){
10+
return true;
11+
}
12+
}
13+
return false; // 모든 값이 고유할 때
14+
}
15+
}

0 commit comments

Comments
 (0)