Your question is Reconstruct Binary Tree Traversals. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Given two integer arrays preorder and inorder representing the preorder and inorder traversals of the same binary tree, reconstruct the binary tree and return its root. Assume all node values are unique, and the traversals are valid.
def build_tree(preorder, inorder):