Skip to content

Conversation

HC-kang
Copy link
Contributor

@HC-kang HC-kang commented Aug 22, 2024

  • Valid Anagram
  • Counting Bits
  • Encode and Decode Strings
  • Construct Binary Tree From Preorder And Inorder Traversal
  • Decode Ways

@HC-kang HC-kang marked this pull request as ready for review August 22, 2024 07:28
@DaleSeo DaleSeo requested a review from ijlijijij August 22, 2024 23:17
Copy link
Member

@DaleSeo DaleSeo left a comment

Choose a reason for hiding this comment

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

수고 많으셨습니다! 잘 푸신 것 같아요!

}

// T.C: O(N)
// S.C: 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.

혹시 공간 복잡도 분석하실 때 문자열 슬라이싱에 들어가는 메모리를 고려하셨을까요?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@DaleSeo 엇 중요한 부분 짚어주셔서 감사합니다 달레님!
슬라이스될 때 마다 복제되는 길이가 대략 절반�씩 줄어 들거라고 생각했는데, 최악의 경우에는 n번의 순회동안 n-1, n-2...1씩 복사를 하겠네요
그렇다면 O(n^2)가 맞을 것 같습니다!

Copy link
Contributor

@ijlijijij ijlijijij left a comment

Choose a reason for hiding this comment

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

고생하셨습니다!

Comment on lines +16 to +24
if (preorder.length === 0 || inorder.length === 0) {
return null;
}
const root = new TreeNode(preorder[0]);
const idx = inorder.indexOf(preorder[0]);
root.left = buildTree(preorder.slice(1, idx + 1), inorder.slice(0, idx));
root.right = buildTree(preorder.slice(idx + 1), inorder.slice(idx + 1));

return root;
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.

좋게 봐 주셔서 감사합니다!

@HC-kang HC-kang merged commit 2397584 into DaleStudy:main Aug 24, 2024
1 of 2 checks 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.

3 participants