LeetCode – Construct Binary Tree from Preorder and Inorder Traversal (Java)

Given preorder and inorder traversal of a tree, construct the binary tree. Analysis Consider the following example: in-order: 4 2 5 (1) 6 7 3 8 pre-order: (1) 2 4 5 3 7 6 8 From the pre-order array, we know that first element is the root. We can find the root in in-order array. … Read more