Skip to content

[jdy8739] Week 11 #1028

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

Merged
merged 9 commits into from
Feb 20, 2025
Merged

[jdy8739] Week 11 #1028

merged 9 commits into from
Feb 20, 2025

Conversation

jdy8739
Copy link
Contributor

@jdy8739 jdy8739 commented Feb 15, 2025

답안 제출 문제

체크 리스트

  • 우측 메뉴에서 PR을 Projects에 추가해주세요.
  • Projects의 오른쪽 버튼(▼)을 눌러 확장한 뒤, Week를 현재 주차로 설정해주세요.
  • 바로 앞에 PR을 열어주신 분을 코드 검토자로 지정해주세요.
  • 문제를 모두 푸시면 프로젝트에서 StatusIn Review로 설정해주세요.
  • 코드 검토자 1분 이상으로부터 승인을 받으셨다면 PR을 병합해주세요.

@jdy8739 jdy8739 requested a review from a team as a code owner February 15, 2025 16:27
@github-actions github-actions bot added the js label Feb 15, 2025
@jdy8739 jdy8739 requested a review from imsosleepy February 15, 2025 16:31
Copy link
Contributor

@HC-kang HC-kang left a comment

Choose a reason for hiding this comment

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

@jdy8739 님 11번째주 정말 빠르게 풀어주셨네요!
시간이 아직 있어서 개선에 대한 의견도 조금 드렸지만, 지금 풀이도 충분히 좋기때문에 승인 먼저 드립니다!

};

// 시간복잡도 O(n) -> 트리의 모든 노드를 재귀적으로 탐색하므로 복잡도는 노드의 수와 비례함
// 공간복잡도 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.

재귀 스택으로 인해 O(n), 혹은 O(h)에 해당하는 공간을 사용할 것 같아요!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

아하 맞네요! 재귀 스택에 대한 생각을 깜빡했습니다. 코멘트 감사합니다! :)

if (endOfArr < next) {
arr.push(sort[i]);
} else {
arr[arr.length - 1][1] = Math.max(arr[arr.length - 1][1], sort[i][1]);
Copy link
Contributor

Choose a reason for hiding this comment

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

arr[arr.length - 1][1]라는 값이 반복 사용되는데, 이게 원시값이다 보니 이렇게 반복 사용되는 것 같아요.
arr[arr.length - 1]를 변수로 할당해서 사용하시면 좀 더 간소화 가능하지 않을까요?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

배열 마지막 인덱스의 원소인 배열을 변수에 저장하고 참조하면 더 읽기 쉬운 코드가 될 것 같네요! 코멘트 감사합니다~

};

// 시간복잡도 O(n) -> while문이 링크드리스트의 길이만큼 순회를하기때문에 링크드리스트의 길이만큼 시간이 걸림
// 공간복잡도 O(n) -> 스택에 모든 노드를 저장하기 때문에 링크드리스트의 길이만큼 공간이 필요
Copy link
Contributor

Choose a reason for hiding this comment

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

지금 풀이도 충분히 좋습니다!
하지만 아무래도 링크드 리스트에 대한 조작 문제이고, 아직 여유 시간도 좀 더 있는 만큼 runner를 사용한 풀이도 한번 시도해보시면 어떨까요?
공간 복잡도를 O(1)으로 줄일 수도 있으니까요!

@jdy8739 jdy8739 merged commit 681733f into DaleStudy:main Feb 20, 2025
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.

2 participants