Leetcode 94. Binary Tree Inorder Traversal (Medium) (cpp)
来源:互联网 发布:艾吉森空气净化器 知乎 编辑:程序博客网 时间:2024/06/01 10:36
Leetcode 94. Binary Tree Inorder Traversal (Medium) (cpp)
Tag: Tree, Hash Table, Stack
Difficulty: Medium
/*94. Binary Tree Inorder Traversal (Medium)Given a binary tree, return the inorder traversal of its nodes' values.For example:Given binary tree [1,null,2,3], 1 \ 2 / 3return [1,3,2].Note: Recursive solution is trivial, could you do it iteratively?*//** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */class Solution {public: vector<int> inorderTraversal(TreeNode* root) { vector<int> res; traversal(root, res); return res; } void traversal(TreeNode* root, vector<int>& res) { if (root) { traversal(root -> left, res); res.push_back(root -> val); traversal(root -> right, res); } }};
0 0
- Leetcode 94. Binary Tree Inorder Traversal (Medium) (cpp)
- LeetCode #94 - Binary Tree Inorder Traversal - Medium
- 【Leetcode-Medium-94】Binary Tree Inorder Traversal
- 94. Binary Tree Inorder Traversal #Medium
- Leetcode 105. Construct Binary Tree from Preorder and Inorder Traversal (Medium) (cpp)
- Leetcode 106. Construct Binary Tree from Inorder and Postorder Traversal (Medium) (cpp)
- Leetcode 144. Binary Tree Preorder Traversal (Medium) (cpp)
- Leetcode 103. Binary Tree Zigzag Level Order Traversal (Medium) (cpp)
- leetcode 日经贴,Cpp code -Binary Tree Inorder Traversal
- 94.LeetCode Binary Tree Inorder Traversal(medium)[中序遍历二叉树 树的遍历]
- LeetCode 94. Binary Tree Inorder Traversal
- [LeetCode]94.Binary Tree Inorder Traversal
- 94. Binary Tree Inorder Traversal Leetcode Python
- [Leetcode] 94. Binary Tree Inorder Traversal
- LeetCode --- 94. Binary Tree Inorder Traversal
- LeetCode 94. Binary Tree Inorder Traversal
- [leetcode] 94.Binary Tree Inorder Traversal
- 94. Binary Tree Inorder Traversal LeetCode
- oracle排查错误sql的一些方法
- ADT或adb显示设备“offline”的一种处理办法
- ppp协议
- java web项目中对于资源文件的读取
- UIScrollView控件实现图片轮播
- Leetcode 94. Binary Tree Inorder Traversal (Medium) (cpp)
- MVC模式理解+小Demo
- [Spring MVC] - Annotation验证
- Xcode运行报错 cannot synthesize weak property in file using manual reference counting
- OSX: 尝试禁止Bonjour广播带来的问题解决(10.11.x或更新)
- Unity开发基础——类型转换学习笔记
- 嵌入式学习-驱动开发-lesson7.1-网卡驱动架构分析驱动及CS8900流程分析
- Python读写csv文件
- Spring MVC 教程,快速入门,深入分析