1. Preorder Names the Root, Inorder Splits the Rest Optimal
Intuition
Each traversal supplies half the answer and neither is enough alone. Preorder visits the root first, so its next unused value is always the root of whatever subtree you are building. Inorder puts everything left of the root in the left subtree and everything right of it in the right, so locating the root there splits the remaining values into exactly those two halves. Recurse on the halves in preorder order and the tree assembles itself. A map from value to inorder index turns the repeated search into a lookup, which is the whole difference between quadratic and linear.
Algorithm
1. Index every value by its position in inorder.
2. Walk preorder with a moving cursor; the value under it is the current root.
3. Look up that value's inorder position to find where the left subtree ends.
4. Build the left subtree from the inorder range before it, then the right from the range after — left first, because that is the order preorder consumes them.
Time & Space
Time O(n) with the index, O(n^2) without it from re-scanning inorder at every node. Space O(n).