Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
[hsskey] Week 02 Solutions #1231
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
[hsskey] Week 02 Solutions #1231
Changes from all commits
60cd657
665564d
a4874d3
fb3974b
036de93
0449874
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
안녕하세요! 좋은 주말입니다.
요 알고리즘 시간복잡도는 O(logN) 으로 생각이 되는데,
제 계산이 맞을까요??
아니라면 얼마나 되는지 궁금합니다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
안녕하세요 @YoungSeok-Choi 님
해당 풀이는 O(logN)이 아닌 O(n) 풀이입니다.
이 문제를 일반적인 이진탐색인 O(logN)으로 보일 수 있으나, 이 문제는 탐색 구현이 아니라
문제의 요구사항은 트리 전체를 확인하는 검증과정이라고 볼 수 있습니다.
풀이 중 조건문을 통과한 코드들은 마지막 return문에서 재귀적으로 동작하게되는데,
이를 시각화해서 보면 왼쪽과 오른쪽으로 코드가 마치 배열을 선형적으로 순회하듯이 거치는것을 확인할 수 있습니다.
따라서 해당 풀이는 O(n)풀이가 됩니다.