c++ simple recursion without the map use detailed explaination
The Idea is As They Given us Inorder and Postorder\n\nas we Know Inorder Fallow --> Left_subtree => Root_Node => Right_subtree Traverse\n   ans   Postorder Fall
The Idea is As They Given us Inorder and Postorder\n\nas we Know Inorder Fallow --> Left_subtree => Root_Node => Right_subtree Traverse\n   ans   Postorder Fallow --> Left_subtree => Right_subtree =>Root_Nodetraverse\nusing Postorder_array We can Find Root_Node Which always lay in Postorder_array last Possition\nAfter Finding That Root_Node ,First we are going to divide Inorder_array Into Two Part and Postorder Array\ninto Two part .\n\nThen We are going to use Both of the arrays left part to Figur Out Left_subtree\n                     and Both of the arraysRigth Part to Figur out Right_subtree\n\nWe are going to recursively do so until One Of the array dose not got empty\nLet\'s take an Example\n\n    inorder   = [4 2 5 1 6 3 7]\n    postorder = [4 5 2 6 7 3 1]\n\n    So root would be 1 here and Left array which lay left of 1 is [4 2 5] and Right of 1 is [6 3 7]\n    so left_inorder_array =  [4 2 5] and right_inorder_arry = [6 3 7]\n\n    using 6 [ which is just rigth of 1] we are going to devide Postorder_array into two part\n    [4 5 2] and [6 7 3]\n\n\n    1st Phase=>        \n\t                   1\n\n                   /        \\\n\n                [4 2 5]   [6 3 7]       <= inorder array\n                [4 5 2]   [6 7 3]       <= postorder array\n\nNow we have new freash problem like need to make tree by using inorder = [4 2 5] && postorder =  [4 5 2] for left subtree \nAND inorder = [6 3 7] && postorder = [6 7 3] for right  subtree \n**now same process we need to do again and again  until One Of the array dose not got empty\nRest of the Process show in a diagram Form :)\n\n    2nd Phase =>\n                           1\n\n                      /        \\\n                     2          3\n                [4]    [5]   [6]   [7]       <= inorder array\n                [4]    [5]   [6]   [7]       <= postorder array\n\n\n3rd Phase =>  \n\t             1\n\n               /    \\\n              2      3\n \n            /  \\    /  \\             <==== Answer\n \n           4    5  6    7 \n\n\n\nin the helper function, IN_SI  and IN_EI : starting index and ending index for the inorder vector\nPOST_SI and POST_EI : starting and ending idx for the postorder vector !! (to mark up the part of vector in consideration for that phase of recursion)\n\t\t\t\t\t\t\t\n```\nclass Solution {\n    TreeNode*helper(vector<int>&in,vector<int>&post,int IN_SI,int IN_EI,int POST_SI,int POST_EI){\n    if(IN_SI > IN_EI){\n        return NULL;\n    }\n    int rootdata = post[POST_EI];\n    int rootindex = -1;\n     for(int i = IN_SI; i<=IN_EI; i++){\n         if(in[i] == rootdata){\n             rootindex = i;\n             break;\n         }\n     }\n     \n            int Left_ins = IN_SI;\n            int Left_ine = rootindex-1;\n            int Left_posts = POST_SI;\n            int Left_poste = Left_ine - Left_ins + Left_posts;\n            int Right_ins = rootindex+1;\n            int Right_ine = IN_EI;\n            int Right_posts = Left_poste + 1;\n            int Right_poste  = POST_EI - 1;  \n        \n    TreeNode*root = new TreeNode(rootdata);\n    root->left = helper(in,post,Left_ins,Left_ine,Left_posts,Left_poste);\n    root->right = helper(in,post,Right_ins,Right_ine,Right_posts,Right_poste);\n    return root;\n            \n        }\npublic:\n    TreeNode* buildTree(vector<int>& inorder, vector<int>& postorder) {\n        int size = inorder.size();\n        return helper(inorder,postorder,0,size-1,0,size-1);\n    \n    }\n};\n```\n
['Recursion', 'C']