Lintcode68 Binary Tree Postorder Traversal solution 题解
来源:互联网 发布:沈阳贵德软件电话 编辑:程序博客网 时间:2024/06/05 21:21
【题目描述】
Given a binary tree, return the postorder traversal of its nodes' values.
给出一棵二叉树,返回其节点值的后序遍历。
【题目链接】
www.lintcode.com/en/problem/binary-tree-postorder-traversal/
【题目解析】
二叉树后序遍历。刚接触leetcode时也做过这道题,用了很蠢笨的方法。现在学习discuss里大神们的版本,真的进步很多。下面这个版本是基于上道题目-二叉树先序遍历的。由于后序遍历是left -> right -> root,先序是root -> left -> right, 所以我们改变的只是如何插入结果到list里,以及被压入栈的先后顺序而已。在这里,pop出的结果要插入到list前部,而且要先把左子树压入栈,其次是右子树。
【参考答案】
www.jiuzhang.com/solutions/binary-tree-postorder-traversal/
阅读全文
0 0
- Lintcode68 Binary Tree Postorder Traversal solution 题解
- Lintcode68 Binary Tree Postorder Traversal solution 题解
- Lintcode72 Construct Binary Tree from Inorder and Postorder Traversal solution 题解
- Lintcode72 Construct Binary Tree from Inorder and Postorder Traversal solution 题解
- LeetCode题解:Binary Tree Postorder Traversal
- LeetCode题解-145-Binary Tree Postorder Traversal
- Lintcode66 Binary Tree Preorder Traversal solution 题解
- Lintcode67 Binary Tree Inorder Traversal solution 题解
- Lintcode67 Binary Tree Inorder Traversal solution 题解
- LeetCode 145. Binary Tree Postorder Traversal java solution
- Binary Tree Postorder Traversal
- Binary Tree Postorder Traversal
- Binary Tree Postorder Traversal
- Binary Tree Postorder Traversal
- Binary Tree Postorder Traversal
- Binary Tree Postorder Traversal
- Binary Tree Postorder Traversal
- Binary Tree Postorder Traversal
- linux 内核配置、编译、
- 序列化和反序列化
- Spark2.0.X源码深度剖析之 Spark Submit..
- 实例探索Java模式之路——适配器模式
- C语言之typedef详解
- Lintcode68 Binary Tree Postorder Traversal solution 题解
- Java:HttpUtils :发送get/post请求
- 打点利器——ActivityLifecycleCallbacks
- 疯狂的bLue(dp)
- 存储的瓶颈终篇(8)
- 西开js 6.3/6.4
- OkHttp基本使用
- 前端进阶——作用域的相关知识
- Qt4.8.6+VS2010安装配置教程