145.Binary Tree Postorder Traversal (二叉树后序遍历)
来源:互联网 发布:gdi高级编程 pdf 编辑:程序博客网 时间:2024/04/30 12:05
Given a binary tree, return the postorder traversal of its nodes' values.
For example:
Given binary tree {1,#,2,3}
,
1 \ 2 / 3
return [3,2,1]
.
代码:
/**
* Definition for a binary tree node.
* public class TreeNode {
* int val;
* TreeNode left;
* TreeNode right;
* TreeNode(int x) { val = x; }
* }
*/
public class Solution {
public List<Integer> postorderTraversal(TreeNode root) {
List<Integer> res = new ArrayList<Integer>();
if(root!=null){
res.addAll(postorderTraversal(root.left));
res.addAll(postorderTraversal(root.right));
res.add(root.val);
}
return res;
}
}
0 0
- 145.Binary Tree Postorder Traversal (二叉树后序遍历)
- LeetCode 145. Binary Tree Postorder Traversal(二叉树后序遍历)
- 145.leetcode Binary Tree Postorder Traversal(easy)[二叉树后序遍历]
- [leetcode-二叉树后序遍历]--145. Binary Tree Postorder Traversal
- 二叉树后序遍历——145. Binary Tree Postorder Traversal
- Leetcode: Binary Tree Postorder Traversal(二叉树后序遍历)
- LeetCode 145 Binary Tree Postorder Traversal(二叉树后序遍历)
- 二叉树遍历145. Binary Tree Postorder Traversal
- leetcode 145. Binary Tree Postorder Traversal 二叉树后续遍历
- Leetcode Binary Tree Postorder Traversal 二叉树后序遍历
- Binary Tree Postorder Traversal 非递归实现二叉树后序遍历
- LeetCode145——Binary Tree Postorder Traversal二叉树后序遍历
- binary-tree-postorder-traversal(后序遍历二叉树)
- Binary Tree Postorder Traversal-二叉树的后序遍历
- Binary Tree Postorder Traversal 二叉树后续遍历@LeetCode
- Binary Tree Postorder Traversal 二叉树的后序遍历
- 【二叉树的后续遍历】Binary Tree Postorder Traversal
- 二叉树的后序遍历 Binary Tree Postorder Traversal
- atom
- dos 命令——切换盘符与切换工作目录
- 【框架-MFC】MFC 获取Windows特殊路径
- 视频显示
- day01
- 145.Binary Tree Postorder Traversal (二叉树后序遍历)
- Core Animation - 9
- Android ORM 框架之 ActiveAndroid
- hdu1059 Dividing(完全背包)
- NSAssert NSCAssert NSParameterAssert
- poj-2632 Crashing Robots
- 使用TextureView setTransform(Matrix)方法,解决Camera显示变形问题
- Andriod Thread状态
- LVS+keepalived负载均衡