-
Notifications
You must be signed in to change notification settings - Fork 126
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
[선재] WEEK 12 Solution #567
Conversation
* | ||
* n = minimum tree node count of p or q | ||
* time complexity: O(n) | ||
* space complexity: O(1) |
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.
콜 스택이 차지하는 메모리도 고려해야하지 않을까요?
* | ||
* n = total length of head node list | ||
* time complexity: O(n) | ||
* space complexity: O(n) |
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(1)
인 것 같은데 혹시 선형 크기만큼 공간을 포함하는 이유가 무엇일까요??
for (let i = 0; i < nodeCount; i++) { | ||
if (nodeCount - n === i) { | ||
i++; | ||
node = node.next; | ||
} | ||
|
||
answerNode.next = node; | ||
answerNode = node; | ||
|
||
node = node?.next ?? null; | ||
} |
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.
저는 임시 리스트를 생성해서 참조를 다 담아서 비효율적으로 풀었었는데, 총 노드 사이즈를 구한 후에 헤드 노드의 참조를 처음부터 다시 갱신하여 n의 위치에서는 건너뛰는 방법 인상깊네요 ㅎㅎ
잘 봤습니다!
답안 제출 문제
체크 리스트
In Review
로 설정해주세요.