由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - Binary Tree Postorder Traversal 求 Recursive solution Java
相关主题
豁出去了,决定怒刷100题LeetCode题Binary Tree Inorder Traversal
请教,Binary Tree Level Traversal有recursive的算法么?F家phone interview的一道题
M家onsite题一道求LeetCode Binary Tree Level Order Traversal II解法
Tree的traversal也分BFS和DFS?Leetcode上Binary Tree Level Order Traversal II的疑问
问几个有关Binary tree的题Binary Tree Level Order Traversal为什么老通不过
说说面了几个老印的体会出个题。reconstruct binary tree
攒人品,amazon一面经历non recursive binary tree traversal in O(n) time and O(1) space
Construct Binary Tree from Inorder and Postorder Traversal请教find number of duplicates in a binary search tree
相关话题的讨论汇总
话题: recursive话题: solution话题: res话题: integer话题: arraylist
进入JobHunting版参与讨论
1 (共1页)
C**5
发帖数: 202
1
使用Stack的网上有,要最简单的 Recursive solution
v**m
发帖数: 706
2
recursive solution is easier.
b*********s
发帖数: 115
3
public class Solution {
public ArrayList postorderTraversal(TreeNode root) {
// IMPORTANT: Please reset any member data you declared, as
// the same Solution instance will be reused for each test case.
ArrayList res = new ArrayList();
visit(res, root);
return res;
}

private void visit(ArrayList res, TreeNode root) {
if (root == null) return;
visit(res, root.left);
visit(res, root.right);
res.add(root.val);
}
}
C**5
发帖数: 202
4
谢谢
1 (共1页)
进入JobHunting版参与讨论
相关主题
请教find number of duplicates in a binary search tree问几个有关Binary tree的题
关于BST traverse的复杂度说说面了几个老印的体会
Interview question::攒人品,amazon一面经历
谁有较好的iterative后序遍历binary tree的代码?Construct Binary Tree from Inorder and Postorder Traversal
豁出去了,决定怒刷100题LeetCode题Binary Tree Inorder Traversal
请教,Binary Tree Level Traversal有recursive的算法么?F家phone interview的一道题
M家onsite题一道求LeetCode Binary Tree Level Order Traversal II解法
Tree的traversal也分BFS和DFS?Leetcode上Binary Tree Level Order Traversal II的疑问
相关话题的讨论汇总
话题: recursive话题: solution话题: res话题: integer话题: arraylist