Skip to content

Commit d4e9f48

Browse files
committed
docs: 105. Construct Binary Tree from Preorder and Inorder Traversal
1 parent 3f79dd8 commit d4e9f48

File tree

1 file changed

+1
-1
lines changed
  • construct-binary-tree-from-preorder-and-inorder-traversal

1 file changed

+1
-1
lines changed

construct-binary-tree-from-preorder-and-inorder-traversal/HC-kang.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class TreeNode {
1111
}
1212

1313
// T.C: O(N)
14-
// S.C: O(N)
14+
// S.C: O(N^2) - Slice makes n-1, n-2, ..., 1 for n times. So, it's O(N^2).
1515
function buildTree(preorder: number[], inorder: number[]): TreeNode | null {
1616
if (preorder.length === 0 || inorder.length === 0) {
1717
return null;

0 commit comments

Comments
 (0)