【Leetcode】145. Binary Tree Postorder Traversal 【递归&&非递归】
来源:互联网 发布:三体水滴视频 知乎 编辑:程序博客网 时间:2024/05/10 17:44
145. Binary Tree Postorder Traversal
- Total Accepted: 108503
- Total Submissions: 295063
- Difficulty: Hard
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]
.
Note: Recursive solution is trivial, could you do it iteratively?
递归代码:
public class Solution { public List<Integer> postorderTraversal(TreeNode root) { List<Integer> res = new ArrayList<Integer>(); if(root == null) return res; preOrder(root,res); return res; } private void preOrder(TreeNode root,List<Integer> res){ if(root == null) return; preOrder(root.left,res); preOrder(root.right,res); res.add(root.val); }}
0 0
- 【Leetcode】145. Binary Tree Postorder Traversal 【递归&&非递归】
- LeetCode 145. Binary Tree Postorder Traversal (非递归和递归解)
- leetcode 145. Binary Tree Postorder Traversal-后续遍历|递归|非递归
- [LeetCode] Binary Tree Postorder Traversal [递归版]
- 145. Binary Tree Postorder Traversal非递归,栈实现
- LeetCode Binary Tree Postorder Traversal 二叉树后序遍历 递归和非递归解法
- 【LeetCode】Binary Tree Postorder Traversal 二叉树后序遍历递归以及非递归算法
- ****(leetcode) Binary Tree Postorder Traversal (tree后序遍历非递归实现)
- Binary Tree Postorder Traversal 非递归实现二叉树后序遍历
- LeetCode Binary Tree Postorder Traversal(二叉树的后序遍历 非递归实现)
- 【leetcode】145Binary Tree Postorder Traversal(二叉树非递归后序遍历)
- 【Leetcode】144. Binary Tree Preorder Traversal 【Tree】【递归&&非递归】
- [leetcode]Binary Tree Postorder Traversal 二叉树后序非递归遍历
- Leetcode【二叉树】:Binary Tree Postorder Traversal 题解(非递归解法),可以说是【二叉树】入门必须掌握
- 【LeetCode-面试算法经典-Java实现】【145-Binary Tree Postorder Traversal(二叉树非递归后序遍历)】
- LeetCode Binary Tree Preorder Traversal (二叉树先序遍历非递归)
- [leetcode] Binary Tree Preorder Traversal 非递归先序遍历
- LeetCode:Binary Tree Traversal(二叉树遍历非递归)
- CSS3 选择器——伪类选择器
- DCT变换、DCT反变换、分块DCT变换
- 23种设计模式汇总
- 实例:Python中*args和**kwargs区别
- mapreduce 中文版 中文翻译
- 【Leetcode】145. Binary Tree Postorder Traversal 【递归&&非递归】
- http://www.jianshu.com/p/2ca7767df08c
- 组合和继承
- CSS3 animation介绍
- android Fragments详解三:实现Fragment的界面
- 【linxu c】driver+socket
- 数据结构实验之排序六:希尔排序
- angularJs 一些API
- 常用软件的常用快捷键