Binary Tree Inorder Traversal
来源:互联网 发布:万网域名控制面板登录 编辑:程序博客网 时间:2024/06/07 01:50
Given a binary tree, return the inorder traversal of its nodes' values.
For example:
Given binary tree {1,#,2,3}
,
1 \ 2 / 3
return [1,3,2]
.
Note: Recursive solution is trivial, could you do it iteratively?
confused what "{1,#,2,3}"
means? > read more on how binary tree is serialized on OJ.
中序遍历 代码如下:
public class Solution { public List<Integer> inorderTraversal(TreeNode root) { List<Integer> res=new ArrayList<Integer>(); if(root==null) return res; if(root.left==null&&root.right==null) { res.add(root.val); return res; } res.addAll(inorderTraversal(root.left)); res.add(root.val); res.addAll(inorderTraversal(root.right)); return res; }}
0 0
- Binary Tree Inorder Traversal
- Binary Tree Inorder Traversal
- Binary Tree Inorder Traversal
- Binary Tree Inorder Traversal
- Binary Tree Inorder Traversal
- Binary Tree Inorder Traversal
- Binary Tree Inorder Traversal
- Binary Tree Inorder Traversal
- Binary Tree Inorder Traversal
- Binary Tree Inorder Traversal
- Binary Tree Inorder Traversal
- Binary Tree Inorder Traversal
- Binary Tree Inorder Traversal
- Binary Tree Inorder Traversal
- Binary Tree Inorder Traversal
- Binary Tree Inorder Traversal
- Binary Tree Inorder Traversal
- Binary Tree Inorder Traversal
- opencv学习之二:运用camshift进行红外视频跟踪。
- mysql union, union all合并两个结果集
- FCM算发在MATLAB中的相关解释
- 华为机试—元素按奇偶排序 (金字塔)
- Valid Parentheses -- leetcode
- Binary Tree Inorder Traversal
- 游泳
- 软件开发流程图示
- MySql对正则表达式的支持
- 安装使用CocoaPods
- 找工作遇到的其他技术问题及解答(2)
- Maximum Subarray -- Leetcode
- poj 1273 & hdu 1532 Drainage Ditches(最大流 )EK,dinic模板
- RVD (Rendezvous daemon)