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 1 문제 풀이 #312

Merged
merged 5 commits into from
Aug 16, 2024
Merged

Conversation

@wooseok123 wooseok123 closed this Aug 12, 2024
@wooseok123 wooseok123 reopened this Aug 12, 2024
@wooseok123 wooseok123 marked this pull request as ready for review August 12, 2024 10:41
@wooseok123 wooseok123 removed their assignment Aug 12, 2024
@wooseok123 wooseok123 marked this pull request as draft August 12, 2024 10:46
};

// TC : O(log n) | SC : O(log n)
// 근데 사실 split 메서드 자체는 o(n)인데, toString과정을 통해 log(n)의 개수만큼 나와버린 것이면 o(log n)이라고 표기해도 되는걸까?
Copy link
Contributor

Choose a reason for hiding this comment

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

넹, 상관없을 것 같습니다. 내장 함수도 직접 구현하신 코드처럼 시간을 소모하니까요 :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

아하 애매한 부분이었는데 감사합니다 :)

@wooseok123 wooseok123 self-assigned this Aug 13, 2024
@wooseok123 wooseok123 marked this pull request as ready for review August 13, 2024 11:34
Comment on lines +13 to +16
const obj = findAllValuesInTree(root, {});
const sortedList = Object.keys(obj)
.map(Number)
.sort((a, b) => a - b);
Copy link
Contributor

@bky373 bky373 Aug 15, 2024

Choose a reason for hiding this comment

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

안녕하세요, 사소한 리뷰 글 남깁니다~
풀이를 보았을 때 재귀적으로 트리를 순회하여 모든 노드의 값을 객체에 저장한 후,
정렬을 위해 한 번 더 모든 값을 순회하는 것으로 이해하였습니다.

시간 복잡도의 차이는 없겠지만, 순회하는 단계를 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.

아하 BST에서 중위 순회를 하는 경우 이미 오름차순으로 정렬되기 때문에 추가로 순회하는 단계가 생략될 수 있다는 말씀이실까요!?

@wooseok123 wooseok123 merged commit f4afc87 into DaleStudy:main Aug 16, 2024
@taekwon-dev taekwon-dev added the js label Aug 17, 2024
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.

5 participants