Medium

Quiz

#106 Construct Binary Tree from Inorder and Postorder Traversal

APPROACH

You are given two integer arrays: inorder, the inorder traversal of a binary tree, and postorder, its postorder traversal. Use both sequences to rebuild and return the binary tree.

Example 1:

Input: inorder = [9,3,15,20,7], postorder = [9,15,7,20,3]
Output: [3,9,20,null,null,15,7]

Example 2:

Input: inorder = [-1], postorder = [-1]
Output: [-1]
1 of 4
1:00

What is the optimal approach for this problem?