The last element of postorder is the current root.

Steps

Get the root

Split inorder array based on its value, then we have leftSubtreeInorder and rightSubtreeInorder.

Based on the length of them, we can get leftSubtreePostorder and rightSubtreePostorder.

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.