a simple recursive way in Go with explanation
A basic idea is that, the last element of slice postorder is root\nAnd we can use root to find out left sub-tree and right sub-tree from inorder\nThen, we go to
A basic idea is that, the last element of slice `postorder` is `root`\nAnd we can use `root` to find out left sub-tree and right sub-tree from `inorder`\nThen, we go to build left/right sub-trees.\nSlice `postorder` and `inorder` of the left sub-tree have the same indexing `[:rootIdx]` from the original `postorder` and `inorder`.\nAs for the right sub-tree, its `inorder` is obtained by skipping the first element of original `inorder` because it is `root`. Then for `postorder`, we skip the last one. \n\n```\nfunc buildTree(inorder []int, postorder []int) *TreeNode {\n\n\tif len(inorder) == 0 && len(postorder) == 0 {\n\t\treturn nil\n\t}\n\n\tpivot := postorder[len(postorder)-1]\n\tpivotIdx := 0\n\tfor inorder[pivotIdx] != pivot {\n\t\tpivotIdx++\n\t}\n\n\tleft := buildTree(inorder[:pivotIdx], postorder[:pivotIdx])\n\tright := buildTree(inorder[pivotIdx+1:], postorder[pivotIdx:len(postorder)-1])\n\n\troot := &TreeNode{pivot, left, right}\n\treturn root\n}\n```
[]