Complete Explanation || Intuition for each step explained || Notes
\n\n\n\nclass Solution {\npublic:\n    TreeNode* getRoot(vector<int>&postorder, map<int, int>&mp, int& rootIdx, int low, int high)\n    {\n        if (low > hig
![image](https://assets.leetcode.com/users/images/ac27336b-6edf-4481-a311-6ac5194959c5_1678928387.4402616.png)\n![image](https://assets.leetcode.com/users/images/24a38530-e97c-4319-80d4-7b7be35bfc10_1678928391.094104.png)\n\n```\nclass Solution {\npublic:\n    TreeNode* getRoot(vector<int>&postorder, map<int, int>&mp, int& rootIdx, int low, int high)\n    {\n        if (low > high) return NULL;\n        \n        int currRoot = postorder[rootIdx--];\n        int inorderRootIdx = mp[currRoot];\n        TreeNode* rootNode = new TreeNode(currRoot);\n        \n        rootNode->right = getRoot(postorder, mp, rootIdx, inorderRootIdx + 1, high);\n        rootNode->left = getRoot(postorder, mp, rootIdx, low, inorderRootIdx - 1);\n        return rootNode;\n    }\n    TreeNode* buildTree(vector<int>& inorder, vector<int>& postorder) \n    {\n        int n = inorder.size();\n        map<int, int>mp;\n        for (int i = 0; i < n; i++) mp[inorder[i]] = i; //mentioned that values are unique\n        \n        int rootIdx = n - 1;\n        TreeNode* root = getRoot(postorder, mp, rootIdx, 0, n - 1);\n        return root;\n    }\n};\n```
['Recursion', 'C', 'Binary Tree', 'C++']