Variation of STRIVER solution, Considering Right Side remaining elements
Approach\nA slight variation of approach used by striver , as post order is left->right->root we calculate right remaining elements first instead of left elemen
# Approach\nA slight variation of approach used by striver , as post order is left->right->root we calculate right remaining elements first instead of left elements, then construct subtrees using recursion.\n\n\n# Code\n```cpp []\n/**\n * Definition for a binary tree node.\n * struct TreeNode {\n *     int val;\n *     TreeNode *left;\n *     TreeNode *right;\n *     TreeNode() : val(0), left(nullptr), right(nullptr) {}\n *     TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n *     TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {}\n * };\n */\nclass Solution {\npublic:\n    TreeNode* bt(vector<int>& inorder , int is , int ie ,vector<int>& postorder , int ps , int pe , map<int ,int>& mpp ){\n\n        if(is > ie || ps > pe){\n            return NULL ;\n        }\n\n        TreeNode *root = new TreeNode(postorder[pe]);\n\n        int pos = mpp[postorder[pe]] ;\n        int right = ie - pos ;\n\n        root->left = bt(inorder , is , pos-1 , postorder , ps , pe - right - 1  , mpp) ;\n\n        root->right = bt(inorder , pos+1 , ie , postorder , pe-right , pe-1 , mpp) ;\n\n        return root ;\n\n    }\n    TreeNode* buildTree(vector<int>& inorder, vector<int>& postorder) {\n\n        map<int ,int> mpp ;\n\n        for(int i = 0 ; i< inorder.size() ;i++){\n            mpp[inorder[i]] = i  ;\n        }\n\n        TreeNode* root = bt(inorder , 0 , inorder.size()-1 , postorder , 0, postorder.size()-1 , mpp) ;\n\n        return root ;\n    }\n};\n```
['Tree', 'Recursion', 'Ordered Map', 'C++']