LintCode 68---Binary Tree Postorder Traversal
/**
* Definition of TreeNode:
* public class TreeNode {
* public int val;
* public TreeNode left, right;
* public TreeNode(int val) {
* this.val = val;
* this.left = this.right = null;
* }
* }
*/ public class Solution {
/**
* @param root: A Tree
* @return: Postorder in ArrayList which contains node values.
*/
List<Integer> list = new ArrayList<>();
public List<Integer> postorderTraversal(TreeNode root) {
hou(root);
return list;
}
public void hou(TreeNode root) {
if(root == null) {
return;
}
hou(root.left);
hou(root.right);
list.add(root.val);
}
}
LintCode 68---Binary Tree Postorder Traversal的更多相关文章
- lintcode:Binary Tree Postorder Traversal 二叉树的后序遍历
题目: 二叉树的后序遍历 给出一棵二叉树,返回其节点值的后序遍历. 样例 给出一棵二叉树 {1,#,2,3}, 1 \ 2 / 3 返回 [3,2,1] 挑战 你能使用非递归实现么? 解题: 递归程序 ...
- 12. Binary Tree Postorder Traversal && Binary Tree Preorder Traversal
详见:剑指 Offer 题目汇总索引:第6题 Binary Tree Postorder Traversal Given a binary tree, return the po ...
- Binary Tree Preorder Traversal and Binary Tree Postorder Traversal
Binary Tree Preorder Traversal Given a binary tree, return the preorder traversal of its nodes' valu ...
- C++版 - LeetCode 145: Binary Tree Postorder Traversal(二叉树的后序遍历,迭代法)
145. Binary Tree Postorder Traversal Total Submissions: 271797 Difficulty: Hard 提交网址: https://leetco ...
- LeetCode: Binary Tree Postorder Traversal 解题报告
Binary Tree Postorder Traversal Given a binary tree, return the postorder traversal of its nodes' va ...
- 【LeetCode】145. Binary Tree Postorder Traversal (3 solutions)
Binary Tree Postorder Traversal Given a binary tree, return the postorder traversal of its nodes' va ...
- 二叉树前序、中序、后序非递归遍历 144. Binary Tree Preorder Traversal 、 94. Binary Tree Inorder Traversal 、145. Binary Tree Postorder Traversal 、173. Binary Search Tree Iterator
144. Binary Tree Preorder Traversal 前序的非递归遍历:用堆来实现 如果把这个代码改成先向堆存储左节点再存储右节点,就变成了每一行从右向左打印 如果用队列替代堆,并且 ...
- LeetCode 145. 二叉树的后序遍历(Binary Tree Postorder Traversal)
145. 二叉树的后序遍历 145. Binary Tree Postorder Traversal 题目描述 给定一个二叉树,返回它的 后序 遍历. LeetCode145. Binary Tree ...
- [LeetCode] Binary Tree Postorder Traversal 二叉树的后序遍历
Given a binary tree, return the postorder traversal of its nodes' values. For example: Given binary ...
- 145. Binary Tree Postorder Traversal
题目: Given a binary tree, return the postorder traversal of its nodes' values. For example:Given bina ...
随机推荐
- EasyUI中对于Grid的隐藏与显示
$('#div_Grid').datagrid('hideColumn', 'mtnDate'); $('#div_Grid').datagrid('showColumn', 'mtnDate');
- legend3---5、lavarel爬坑杂记
legend3---5.lavarel爬坑杂记 一.总结 一句话总结: 边做边学,变学边做,可能会节约很多时间,熟悉的就跳着看,不熟悉的就慢慢看 1.如何tags表中的主键是t_id而非id,如何使用 ...
- .NET Assembly File Format
https://docs.microsoft.com/en-us/dotnet/standard/assembly/file-format .NET defines a binary file for ...
- Log4j(详解)
Log4j: Log4j是Apache的一个开源项目,通过使用Log4j,我们可以控制日志信息输送的目的地是控制台.文件.GUI组件, 甚至是套接口服务器.NT的事件记录器.UNIX Syslog守护 ...
- idea中git远程版本回退
idea中git远程版本回退 2017年10月15日 15:25:36 gomeplus 阅读数:19313 工作中遇到git远程仓库需要回退到历史版本的问题,根据网上的搜索结果结合自己的实践,整理了 ...
- 模拟SQLserver IO压力测试 工具编 SQLIOSIM
描述 最近有业务需求需了解客户的服务器SQLserver 的IO情况,而不仅仅是通过系统计数器 了解硬盘的IO情况或者使用CrystalDiskMark或者Trace重播进行压力测试 .这时SQL S ...
- mingw32-gcc-9.2.1-i686-posix-sjlj-20190904-8ba5c53
gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=d:/msys/mingw32/bin/../libexec/gcc/ ...
- debian中安装gcc make
ubuntu debian 可以直接 apt-get install gcc automake autoconf libtool make
- js中的堆内存和栈内存
我们常常会听说什么栈内存.堆内存,那么他们到底有什么区别呢,在js中又是如何区分他们的呢,今天我们来看一下. 一.栈内存和堆内存的区分 一般来说,栈内存主要用于存储各种基本类型的变量,包括Boolea ...
- python中的set集合
当使用爬虫URL保存时,一般会选择set来保存urls,set是集合,集合中的元素不能重复,其次还有交集,并集等集合的功能, 爬虫每次获取的网页中提取网页中的urls,并保存,这就需要利用urls = ...