Description:
Solution:
In the recursion, we set the root and mid, and then divide two portion: right & left.
- root is always the first value of preorder[]
- mid is always the index of root of inorder[]
- left portion: preorder[1: mid+1] and inorder[:mid].
- right portion: preorder[mid+1:] and inorder[mid+1:].
'LeetCode ๐๏ธ > Tree' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
297. Serialize and Deserialize Binary Tree (0) | 2023.06.04 |
---|---|
98. Validate Binary Search Tree (0) | 2023.06.03 |
572. Subtree of Another Tree (0) | 2023.04.02 |
102. Binary Tree Level Order Traversal (0) | 2023.03.21 |
124. Binary Tree Maximum Path (0) | 2023.03.20 |