LintCode 68 二叉树的中序遍历
来源:互联网 发布:linux重启apache 编辑:程序博客网 时间:2024/05/18 03:59
题目:inorderTraversal
要求:
给出一棵二叉树,返回其中序遍历
样例:
给出二叉树 {1,#,2,3}, 1 \ 2 / 3返回 [1,3,2].
算法要求:
你能使用非递归算法来实现么?
解题思路:
直接递归搞定啦~
算法如下:
vector<int> vec; void mDisplay(TreeNode *root) { if (root == NULL) { return; } mDisplay(root->left); vec.push_back(root->val); mDisplay(root->right); } vector<int> inorderTraversal(TreeNode *root) { // write your code here vec.clear(); mDisplay(root); return vec; }
0 0
- LintCode -- 二叉树的中序遍历
- lintcode 二叉树的中序遍历
- lintcode:二叉树的中序遍历
- lintcode,二叉树的中序遍历
- LintCode-二叉树的中序遍历
- Lintcode 二叉树的中序遍历
- Lintcode 二叉树的中序遍历
- LintCode 二叉树的中序遍历
- 二叉树的中序遍历-LintCode
- lintcode二叉树的中序遍历
- LintCode 二叉树的中序遍历
- lintcode--二叉树的中序遍历
- lintcode--二叉树的中序遍历
- LintCode 68 二叉树的中序遍历
- lintcode-二叉树的中序遍历(非递归)-67
- Lintcode 67 二叉树的中序遍历
- lintcode——二叉树的中序遍历
- lintcode 67 二叉树的中序遍历
- 55. Jump Game
- HDOJ 2010 水仙花数
- LintCode 67 二叉树的后序遍历
- java设计模式——观察者模式
- Linux 访问网络文件共享服务
- LintCode 68 二叉树的中序遍历
- spring cloud学习笔记
- Java知识点(四)——多线程
- 551. Student Attendance Record I
- 编译opencv+opencv_contrib源码实现KCF跟踪算法
- Android 开发 Tip 9 -- TouchDelegate
- 4870: [Shoi2017]组合数问题
- java之hashset与hashmap总结
- Python 中的闭包(2)—— 一个栗子