https://leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal
1. Line 9, definitely check null of inputs
2. Line 12, pop() pops last element, pop(0) pops from beginning
3. Line 12, you want to create a root. cuz preorder and inorder only contains int
4. Line 15,16, build left subtree then right subtree. For constructing b-tree from postorder and inorder, build right sub tree first then left subtree
1. line 8, old drill, check inputs
2. line 11, we are using postorder to build b-tree. root node locates at the end of postorder
3. line 14/15, build right sub tree first, then left sub tree.
No comments:
Post a Comment