## Binary Tree Inorder Traversal 原

哭哭吓唬你

For example:
Given binary tree {1,#,2,3},

``````1
\
2
/
3``````

return [1,3,2].

``````/**
* Definition for binary tree
* public class TreeNode {
*     int val;
*     TreeNode left;
*     TreeNode right;
*     TreeNode(int x) { val = x; }
* }
*/
public class Solution {
public List<Integer> inorderTraversal(TreeNode root) {
List<Integer> list = new ArrayList<Integer>();
Deque<TreeNode> stack = new ArrayDeque<TreeNode>();

TreeNode p = root;

while(p!=null || !stack.isEmpty()){
while(p!=null){
stack.push(p);
p = p.left;
}
if(!stack.isEmpty()){
p = stack.pop();
p = p.right;
}
}

return list;
}
}``````

### 哭哭吓唬你

HDU 1710 Binary Tree Traversals

Binary Tree Traversals 　　A binary tree is a finite set of vertices that is either empty or consists of a root r and two disjoint binary trees called the left and right subtre......

suvvm
2018/11/04
0
0
ZOJ Problem Set - 1944 Tree Recovery(二叉树三种遍历知二求三）

Tree Recovery Time Limit: 2 Seconds Memory Limit: 65536 KB Little Valentine liked playing with binary trees very much. Her favorite game was constructing randomly looking binary......

hushhw
2017/11/27
0
0
LeetCode-105 Construct Binary Tree from Preorder and Inorder Traversal

HaoPeng_Zhang
09/18
0
0
Binary Tree Traversal

Binary Tree Preorder Traversal public class Solution { public ArrayList<Integer> preorderTraversal(TreeNode root) { ArrayList<Integer> res = new ArrayList<Integer>(); if(root ==......

LuXing
2014/05/05
8
0

dby_freedom
07/01
0
0

Spring Boot + Mybatis + Ehcache 二级缓存实例

xiaolyuh
22分钟前
4
0
Spring源码学习(二)哎呦，按菜谱做菜与AbstractAutowireCapableBeanFactory.createBean流程差不多

24分钟前
36
0

26分钟前
5
0

6
0
win服务器管理遇到的一系列问题记录

1717197346

6
0