Skip to content

Commit

Permalink
fix solution: Construct Binary Tree from Preorder and Inorder Traversal
Browse files Browse the repository at this point in the history
  • Loading branch information
GotPrgmer committed Dec 26, 2024
1 parent b8ae18e commit 06da82c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion binary-tree-level-order-traversal/Gotprgmer.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

// 시간복잡도 : O(N^2) -> 한쪽으로 치우친 트리일 경우 O(N)(index of) + T(N-1)이 될 수 있다.
// 위 식을 전개해보면 N + N-1 + N-2 + ... + 1 = N(N+1)/2 = O(N^2)
// 공간복잡도 : O(N) -> N길이의 리스트 크기
// 공간복잡도 : O(N) ->리트코드 but N길이의 리스트 크기*N번의 재귀호출이 일어날 수 있다. 따라서 O(N^2)가 아닌가...?
class SolutionGotprgmer {
public TreeNode buildTree(int[] preorder, int[] inorder) {

Expand Down

0 comments on commit 06da82c

Please sign in to comment.