方法一:(递归)

class Solution
{
public:
vector<int> inorderTraversal(TreeNode* root)
{
vector<int> v;
inorderTraversalHelp(root, v);
return v;
} void inorderTraversalHelp(TreeNode *root, vector<int>& v)
{
if(root)
{
inorderTraversalHelp(root->left, v);
v.push_back(root->val);
inorderTraversalHelp(root->right, v);
}
}
};

方法二:

LeetCode 094 Binary Tree Inorder Traversal的更多相关文章

  1. Java for LeetCode 094 Binary Tree Inorder Traversal

    解题思路: 中序遍历,左子树-根节点-右子树 JAVA实现如下: public List<Integer> inorderTraversal(TreeNode root) { List&l ...

  2. [leetcode] 94. Binary Tree Inorder Traversal 二叉树的中序遍历

    题目大意 https://leetcode.com/problems/binary-tree-inorder-traversal/description/ 94. Binary Tree Inorde ...

  3. 49. leetcode 94. Binary Tree Inorder Traversal

    94. Binary Tree Inorder Traversal    二叉树的中序遍历 递归方法: 非递归:要借助栈,可以利用C++的stack

  4. 【LeetCode】Binary Tree Inorder Traversal

    Binary Tree Inorder Traversal Total Accepted: 16406 Total Submissions: 47212My Submissions Given a b ...

  5. leetcode -day29 Binary Tree Inorder Traversal &amp; Restore IP Addresses

    1.  Binary Tree Inorder Traversal Given a binary tree, return the inorder traversal of its nodes' ...

  6. [LeetCode]题解(python):094 Binary Tree Inorder Traversal

    题目来源 https://leetcode.com/problems/binary-tree-inorder-traversal/ iven a binary tree, return the ino ...

  7. Leetcode 94. Binary Tree Inorder Traversal

    Given a binary tree, return the inorder traversal of its nodes' values. For example:Given binary tre ...

  8. leetcode 94 Binary Tree Inorder Traversal ----- java

    Given a binary tree, return the inorder traversal of its nodes' values. For example:Given binary tre ...

  9. Java [Leetcode 94]Binary Tree Inorder Traversal

    题目描述: Given a binary tree, return the inorder traversal of its nodes' values. For example:Given bina ...

随机推荐

  1. for语句嵌套循坏性能的剖析

    日常工作中,处理数据难免会遇到遍历,for循环可能是我们用的比较多的了.本节就来探讨下for语句嵌套循环的性能,猜想下面两个语句的性能. 语句1 ; i < ; i++){ ; j < ; ...

  2. 关于DYNPRO程序的系统迁移与版本不匹配问题之一

    前段时间公司做的一个项目,这两天在将项目程序导入公司,出问题了,搞了半天才发现是系统版本问题,但是还是不知道怎么解决,纠结ING... DYNRPO程序在创建(或是首次运行)的时候会自动生成一个DYN ...

  3. sqlite数据库的使用helper

    public class SQLiteHelper     {         //public static String ConnectionString = "Data Source= ...

  4. 学习iOS【3】数组、词典和集合

    一.数组 1.不可变数组NSArray arrayWithObjects:使用一组对象作为元素创建不可变数组,注意数组的最后一个值需要指定为nil,用来表示参数的结束,但是nil并不会存储在数组中. ...

  5. b/s 读取多个FTP文件(图片,视频)压缩到服务器 下载到客户端

    其实需求是这样, 要做一键导出, 有图片,有照片,youhtml,存在不同的文件夹,每次下载都必须下载最新数据,因为FTP是随时更新的. 1.这要是一直下载下载,浏览器一直跳窗口,蛋疼的我都看不下去. ...

  6. jboss设置图片上传大小

    <http-listener name="default" socket-binding="http" max-post-size="10485 ...

  7. 如何更方便地调试javascript代码

    开发者工具 现在一般的浏览器都内置了开发者工具,快捷键F12可以打开,如Chrome浏览器下,Sources面板下找到对应的js文件 这是首选方法,但是对于SPA程序(比如easyui),可能找不到内 ...

  8. sql 查询服务器硬盘剩余空间

    DECLARE @tb1 Table( drive varchar(20), [MB 可用空间] varchar(20)) INSERT INTO @tb1 Exec master.dbo.xp_fi ...

  9. C++ 之引用

    int argc ,char * argv[] - argument count & argument vector argc - 命令行参数个数,argv[]依次指向每一个命令行参数,其中a ...

  10. Javascript下拉导航

    1.右侧导航 tree.js function Toggle(e){ if(!document.getElementById) return; if(!e) var e = window.event; ...