解题思路:

中序遍历,左子树-根节点-右子树

JAVA实现如下:

    public List<Integer> inorderTraversal(TreeNode root) {
List<Integer> list = new ArrayList<Integer>();
if(root==null)
return list;
if (root.left != null)
list.addAll(inorderTraversal(root.left));
list.add(root.val);
if (root.right != null)
list.addAll(inorderTraversal(root.right));
return list;
}

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

  1. LeetCode 094 Binary Tree Inorder Traversal

    方法一:(递归) class Solution { public: vector<int> inorderTraversal(TreeNode* root) { vector<int ...

  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 ----- java

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

  8. Java [Leetcode 94]Binary Tree Inorder Traversal

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

  9. Leetcode 94. Binary Tree Inorder Traversal

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

随机推荐

  1. Android自定义控件-Path之贝赛尔曲线和手势轨迹、水波纹效果

    从这篇开始,我将延续androidGraphics系列文章把图片相关的知识给大家讲完,这一篇先稍微进阶一下,给大家把<android Graphics(二):路径及文字>略去的quadTo ...

  2. yield理解

    http://www.jianshu.com/p/d09778f4e055 从yield处返回一个值,下次从yield后开始执行

  3. EasyMvc入门教程-基本控件说明(1)按钮

    按钮是我们最常用的控件之一了,先看下我们提供的按钮风格: 不同颜色的: 实现代码: @Html.Q().Button().Text("Danger").ColorDanger() ...

  4. 使用Shiro

    一.架构 要学习如何使用Shiro必须先从它的架构谈起,作为一款安全框架Shiro的设计相当精妙.Shiro的应用不依赖任何容器,它也可以在JavaSE下使用.但是最常用的环境还是JavaEE.下面以 ...

  5. CodeForces - 344B Simple Molecules (模拟题)

    CodeForces - 344B id=46665" style="color:blue; text-decoration:none">Simple Molecu ...

  6. JAVA_StandardServer await create[8005]怎么办

    Tomcat 6.0 错误信息: 严重: StandardServer.await:create[8005]: java.net.BindException: Address already in u ...

  7. JSBridge深度剖析

    概述 做过混合开发的人都知道Ionic和PhoneGap之类的框架,这些框架在web基础上包装一层Native.然后通过Bridge技术的js调用本地的库. 在讲JSBridge技术之前.我们来看一下 ...

  8. 【Excle数据透视表】如何创建非共享缓存的数据透视表

    一般情况下,利用同一个数据源创建多个数据表时,默认创建的是共享缓存的数据透视表.刷新一个数据透视表时会影响其他数据透视表的展示结果. 解决方案 创建非共享缓存的多个数据透视表 步骤一 单击工作表数据任 ...

  9. HTTP头解读

    Http协议定义了很多与服务器交互的方法,最基本的有4种,分别是GET.POST.PUT.DELETE.一个URL地址用于描述一个网络上的资源, 而HTTP中的GET.POST.PUT. DELETE ...

  10. win7 iis6怎么部署.net网站

    win7 iis6怎么部署.net网站,把本机当成网站服务器来简单介绍. 方法/步骤 1 首先在本机有一个可以正常运行的网站.比如vs2010中有一个网站项目,网站项目运行后正常. 2 打开iis6, ...