Monday, March 7, 2016

LeetCode Q105: Construct Binary Tree from Preorder and Inorder Traversal

Given preorder and inorder traversal of a tree, construct the binary tree.
Note:
You may assume that duplicates do not exist in the tree.

Solution:
Basic binary tree question, but need to take care of boundary of array index.




Round2 solution:
Following solution is shorter, though result in a Memory Limit Exceeded.

No comments:

Post a Comment