Skip to content
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

Merged
merged 3 commits into from
Nov 3, 2024
Merged

[선재] WEEK 12 Solution #567

merged 3 commits into from
Nov 3, 2024

Conversation

Sunjae95
Copy link
Contributor

@Sunjae95 Sunjae95 commented Oct 28, 2024

답안 제출 문제

체크 리스트

  • PR을 프로젝트에 추가하고 Week를 현재 주차로 설정해주세요.
  • 바로 앞에 PR을 열어주신 분을 코드 검토자로 지정해주세요.
  • 문제를 모두 푸시면 프로젝트에서 Status를 In Review로 설정해주세요.
  • 코드 검토자 1분 이상으로부터 승인을 받으셨다면 PR을 병합해주세요.

@Sunjae95 Sunjae95 requested a review from jdalma October 28, 2024 10:01
@Sunjae95 Sunjae95 self-assigned this Oct 28, 2024
@github-actions github-actions bot added the js label Oct 28, 2024
*
* n = minimum tree node count of p or q
* time complexity: O(n)
* space complexity: O(1)
Copy link
Contributor

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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 해답의 공간복잡도는 O(1)인 것 같은데 혹시 선형 크기만큼 공간을 포함하는 이유가 무엇일까요??

Comment on lines +23 to +33
for (let i = 0; i < nodeCount; i++) {
if (nodeCount - n === i) {
i++;
node = node.next;
}

answerNode.next = node;
answerNode = node;

node = node?.next ?? null;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

저는 임시 리스트를 생성해서 참조를 다 담아서 비효율적으로 풀었었는데, 총 노드 사이즈를 구한 후에 헤드 노드의 참조를 처음부터 다시 갱신하여 n의 위치에서는 건너뛰는 방법 인상깊네요 ㅎㅎ
잘 봤습니다!

@Sunjae95 Sunjae95 marked this pull request as ready for review November 1, 2024 09:08
@Sunjae95 Sunjae95 requested a review from a team as a code owner November 1, 2024 09:08
@SamTheKorean SamTheKorean merged commit bcc02f2 into DaleStudy:main Nov 3, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
Status: Completed
Development

Successfully merging this pull request may close these issues.

4 participants