Super simple Java solution // beat 100%
\n/**\n * Definition for a binary tree node.\n * public class TreeNode {\n *     int val;\n *     TreeNode left;\n *     TreeNode right;\n *     TreeNode(int x)
```\n/**\n * Definition for a binary tree node.\n * public class TreeNode {\n *     int val;\n *     TreeNode left;\n *     TreeNode right;\n *     TreeNode(int x) { val = x; }\n * }\n */\nclass Solution {\n    \n    private int idx;\n    \n    public TreeNode buildTree(int[] inorder, int[] postorder) {\n        if (inorder.length != postorder.length) return null;\n        if (inorder.length == 0) return null;\n        idx = postorder.length-1;\n        TreeNode root = build(inorder, postorder, 0, idx);\n        return root;\n    }\n    \n    private TreeNode build(int[] inorder, int[] postorder, int start, int end) {\n        if (start>end) return null;\n        TreeNode node = new TreeNode(postorder[idx--]);\n        if (start==end) return node;\n        \n        int index = findIdx(inorder, node.val, end);\n        node.right = build(inorder, postorder, index+1, end);\n        node.left = build(inorder, postorder, start, index-1);\n        return node;\n    }\n    \n    private int findIdx(int[] inorder, int val, int end) {\n        for (int i=end; i>=0; i--) {\n            if (inorder[i]==val) return i;\n        }\n        return 0;\n    }\n}\n// TC: O(N^2)\n// AS: O(N)\n// The worst case falls into the case when tree is a skew tree\n```
['Tree', 'Java']