-
-
Notifications
You must be signed in to change notification settings - Fork 245
[윤태권] Week1 문제 풀이 #317
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[윤태권] Week1 문제 풀이 #317
Changes from 1 commit
bacf40e
c75f0f1
003b675
fbc65ac
a1ff55e
1be1c5b
ca2017a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
class Solution { | ||
/** | ||
* 시간 복잡도: O(N) | ||
* - 최악의 경우 주어진 배열의 마지막 원소까지 체크해야 함. | ||
* - 중복 검사를 위해 Set 선택한 이유 | ||
* - O(1) 으로 탐색 가능 | ||
* - 데이터 순서 보장 필요 없음 | ||
*/ | ||
public boolean containsDuplicate(int[] nums) { | ||
HashSet<Integer> set = new HashSet<>(); | ||
|
||
for (int num: nums) { | ||
if (set.contains(num)) { | ||
return true; | ||
} | ||
set.add(num); | ||
} | ||
return false; | ||
} | ||
} |
Uh oh!
There was an error while loading. Please reload this page.