LeetCode145-Binary-Tree-Postorder-Traversal
来源:互联网 发布:淘宝店铺如何快速升钻 编辑:程序博客网 时间:2024/06/05 16:24
LeetCode 145 : Binary Tree Postorder Traversal
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].
来源: https://leetcode.com/problems/binary-tree-postorder-traversal/
问题描述:
本题其实就是将二叉树按照后序遍历将其值保存在List中。
我的Java代码:
/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */public class Solution { private List<Integer> list ; public List<Integer> postorderTraversal(TreeNode root) { list = new ArrayList<Integer>(); postorder(root); return list; } private void postorder(TreeNode node){ if(null==node){ return ; }else{ postorder(node.left); postorder(node.right); list.add(node.val); return ; } }}
0 0
- Binary Tree Postorder Traversal leetcode145
- LeetCode145:Binary Tree Postorder Traversal
- LeetCode145-Binary-Tree-Postorder-Traversal
- LeetCode145. Binary Tree Postorder Traversal
- leetcode145. Binary Tree Postorder Traversal
- LeetCode145—Binary Tree Postorder Traversal
- Leetcode145——Binary Tree Postorder Traversal
- LeetCode145. Binary Tree Postorder Traversal(hard)
- Leetcode145: Construct Binary Tree from Inorder and Postorder Traversal
- LeetCode145——Binary Tree Postorder Traversal二叉树后序遍历
- LeetCode145 Binary Tree Postorder Traversal(迭代实现) Java
- LeetCode145 Binary Tree Postorder Traversal Java题解(递归 迭代)
- Binary Tree Postorder Traversal
- Binary Tree Postorder Traversal
- Binary Tree Postorder Traversal
- Binary Tree Postorder Traversal
- Binary Tree Postorder Traversal
- Binary Tree Postorder Traversal
- CircuitBreakingException[[FIELDDATA] Data too large, data for [proccessDate] would be larger than li
- LeetCode144-Binary-Tree-Preorder-Traversal
- c#—细说多线程(3)
- 循环15~17
- 页面跳转 和虚拟键盘的自动隐藏
- LeetCode145-Binary-Tree-Postorder-Traversal
- BZOJ2734: [HNOI2012]集合选数|状压DP
- UVa 455 Periodic Strings
- LeetCode102-Binary-Tree-Level-Order-Traversal
- selenuim-webdriver注解之@FindBy、@FindBys、@FindAll的区别
- 剑指Offer-二维数组中的查找
- UVa 227 Puzzle
- NoSQL
- Android 高仿微信6.0主界面 切换图标变色