faster than 100% very well explained c++ solution using recursion
/\n  Definition for a binary tree node.\n  struct TreeNode {\n      int val;\n      TreeNode left;\n      TreeNode right;\n      TreeNode() : val(0), left(nullp
/\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 /\n\nclass Solution {\npublic:\n    int postindex;//to traverse the postorder vector\n    unorderedmap<int,int>m;//to store the index value of inorder\n    TreeNode arraytotree(vector<int>&postorder,int left,int right)\n    {\n        //terminating conditon of the recursive call\n        if(left>right)\n            return NULL;\n        //postorderindex will give root value as preorder traversal is LEFT->RIGHT->ROOT\n        int rootval=postorder[postindex];\n        postindex--;//decrementing by one\n        // rootval will be root of tree so declaring tree with rootval.\n        TreeNode root=new TreeNode(rootval);\n         //recursively call fuction on the left and right subtree \n        root->right=arraytotree(postorder,m[rootval]+1,right);//right tree will contain all the element right to the rootval in inorder vector\n        root->left=arraytotree(postorder,left,m[rootval]-1);//left tree will contain all the element left to the rootval in inorder vector\n        return root;\n    }\n    TreeNode buildTree(vector<int>& inorder, vector<int>& postorder) {\n        postindex=postorder.size()-1;\n        for(int i=0;i<inorder.size();i++)\n            m[inorder[i]]=i;//storing the index val for postorder traversal\n        TreeNode root=arraytotree(postorder,0,postorder.size()-1);\n        return root;\n    }\n};\nplz upvote if you find it useful....that would be motivating...
['Recursion', 'C', 'C++']