Construct binary tree form postorder and inorder--LeetCode
来源:互联网 发布:美化照片软件 编辑:程序博客网 时间:2024/06/05 05:14
和上面的题目相似 思路也是类似
Tree* helpersecond(vector<int>& inorder,int in_begin,int in_end,vector<int>& post,int post_begin,int post_end){Tree* root =NULL;int mid;int i;if(in_begin > in_end){return NULL;}else{for(i=in_begin;i<=in_end;i++)if(inorder[i] == post[post_end])break;if(i > in_end)return NULL;root = new Tree;root->value = post[post_end];root->left = helpersecond(inorder,in_begin,i-1,post,post_begin+i,post_end-1);root->right =helpersecond(inorder,i+1,in_end,post,post_begin,post_begin+i-1);}}Tree* createBinTree(vector<int>& inorder,vector<int>& post) {if(inorder.size()==0 || post.size()==0)return NULL;return helpersecond(inorder,0,inorder.size()-1,post,0,post.size()-1);}
0 0
- Construct binary tree form postorder and inorder--LeetCode
- *(leetcode) Construct Binary Tree from Inorder and Postorder Traversal (tree)
- LeetCode[Tree]: Construct Binary Tree from Inorder and Postorder Traversal
- LeetCode: Construct Binary Tree from Inorder and Postorder Traversal
- [LeetCode]Construct Binary Tree from Inorder and Postorder Traversal
- LeetCode Construct Binary Tree from Inorder and Postorder Traversal
- LeetCode: Construct Binary Tree from Inorder and Postorder Traversal
- LeetCode: Construct Binary Tree from Inorder and Postorder Traversal
- [LeetCode] Construct Binary Tree from Inorder and Postorder Traversal
- LeetCode Construct Binary Tree from Inorder and Postorder Traversal
- [Leetcode] Construct Binary Tree from Inorder and Postorder Traversal
- leetcode 110: Construct Binary Tree from Inorder and Postorder Traversal
- 【leetcode】Construct Binary Tree from Inorder and Postorder Traversal
- [LeetCode]Construct Binary Tree from Inorder and Postorder Traversal
- [leetcode]Construct Binary Tree from Inorder and Postorder Traversal
- LeetCode-Construct Binary Tree from Inorder and Postorder Traversal
- [leetcode] Construct Binary Tree from Inorder and Postorder Traversal
- LeetCode - Construct Binary Tree from Inorder and Postorder Traversal
- Java反射机制浅析
- 360奇云测测试网站的加载速度
- Protocol Buffer技术详解(语言规范)
- 学习笔记
- Retrieving the COM class factory for component with CLSID {30707210-52D5-11D0-A8F2-00608C85EDE5} fai
- Construct binary tree form postorder and inorder--LeetCode
- ANDROID 架构师微课程分享 视频课程
- Linux操作系统 入门级命令汇总
- ArcGIS Desktop Add-in插件开发
- 不声明第三个变量,交换两个变量的值
- makefile编写规则
- PDF转换成word免费转换器
- edk 2 的基本架构
- 声明第三个变量交换两个变量值