Given two integer arrays inorder and postorder where inorder is the inorder traversal of a binary tree and postorder is the postorder traversal of the same tree, construct 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]
Explanation: The last postorder value, 3, is the root. In the inorder list, 9 sits left of 3 (the left subtree) and [15,20,7] sits right of it. Applying the same rule to the right part makes 20 its root, with 15 on the left and 7 on the right.
Example 2
Input: inorder = [-1], postorder = [-1]
Output: [-1]
Explanation: Both traversals contain only -1, so the tree is that single node.
Example 3
Input: inorder = [2,1], postorder = [2,1]
Output: [1,2]
Explanation: The last postorder value, 1, is the root. In inorder, 2 comes before 1, so 2 is 1's left child.
Postorder visits the root last, so read postorder from the back to get roots. Each root splits inorder into left/right subtrees. Because we consume postorder in reverse (root, then right subtree, then left), build the right child before the left.
Run checks all cases above. Submit evaluates all test cases.