# Definition for a binary tree node.
# class TreeNode(object):
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None class Solution(object):
def inorderTraversal(self, root):
"""
:type root: TreeNode
:rtype: List[int]
"""
res=[]
stk=[]
if root == None:
return res
while root != None or len(stk) != 0:
if root != None:
stk.append(root)
root=root.left
elif len(stk) != 0:
tmpNode=stk.pop()
res.append(tmpNode.val)
root=tmpNode.right
return res

leetcode Binary Tree Inorder Traversal python的更多相关文章

  1. LeetCode: Binary Tree Inorder Traversal 解题报告

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

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

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

  3. Leetcode Binary Tree Inorder Traversal

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

  4. [Leetcode] Binary tree inorder traversal二叉树中序遍历

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

  5. [LeetCode] Binary Tree Inorder Traversal 中序排序

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

  6. [leetcode]Binary Tree Preorder Traversal @ Python

    原题地址:http://oj.leetcode.com/problems/binary-tree-preorder-traversal/ 题意:这题用递归比较简单.应该考察的是使用非递归实现二叉树的先 ...

  7. leetcode Binary Tree Postorder Traversal python

    # Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = ...

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

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

  9. [线索二叉树] [LeetCode] 不需要栈或者别的辅助空间,完成二叉树的中序遍历。题:Recover Binary Search Tree,Binary Tree Inorder Traversal

    既上篇关于二叉搜索树的文章后,这篇文章介绍一种针对二叉树的新的中序遍历方式,它的特点是不需要递归或者使用栈,而是纯粹使用循环的方式,完成中序遍历. 线索二叉树介绍 首先我们引入“线索二叉树”的概念: ...

随机推荐

  1. sctf pwn400

    这个题目在这个链接中分析得很透彻,不再多余地写了.http://bruce30262.logdown.com/posts/245613-sctf-2014-pwn400 exploit: from s ...

  2. T-SQL存储过程

    存储过程(procedure)就是一个函数,完成一段sql代码的封装,实现代码的重用.    优点:         1.比使用DotNet直接写Sql脚本执行少了一块解析编译的过程.效率更快一点点. ...

  3. Android Studio之build.gradle小技巧

    一: 当你工程引用android 的support包的时候,常常会这样写: dependencies { compile 'com.android.support:recyclerview-v7:22 ...

  4. C#性能优化实践 资料整理

    缓存(Cache)是性能优化中最常用的优化手段.适用的情况是频繁的获取一些数据,而每次获取这些数据需要的时间比较长.这时,第一次获取的时候会用正常的方法,并且在获取之后把数据缓存下来.之后就使用缓存的 ...

  5. sencha touch 2.3 结合cordova 环境搭建

    sencha touch 2.3环境搭建必备工具 sencha touch 2.3 包sencha cmd 4.0以上JAVA JDK 1.7以上(注意JDK和JRE的区别)Ruby 1.9.3或更早 ...

  6. ajax查询数据的举例

    1.根据下拉框的值异步查询信息 HTML代码如下: <script> $(function(){ //页面载入时执行 $("#key").change(function ...

  7. SQL Server 从数据库快照还原数据库

    语法: restore database db_name from database_snapshot  = 'db_snapshot_name'; ------------------------- ...

  8. shell script 零碎知识

    1.test命令的测试功能 -e  文件名是否存在 -f  文件名是否存在且为文件 -d  文件名是否存在且为目录 范例1    检查/dmtsai是否存在,存在输出 exist  不存在输出 Not ...

  9. 可以使用QT给龙芯开发软件

    直接apt-get install libqt5core5a就有了,也许是一个很好的小众市场机会呢 至于系统,可以使用debian mips https://www.debian.org/devel/ ...

  10. perl /m修饰符使用说明

    高级用法: 多行匹配: grok正则和普通正则一样, 默认是不支持匹配回车换行的. perl的/m选项 The /m modifier allows ^ and $ to match immediat ...