Leetcode 145. Binary Tree Postorder Traversal
後根遍歷二叉樹
方法1:遞迴
class Solution {
public:
void help(TreeNode* root, vector <int> &re)
{
if (!root) return;
help(root->left, re);
help(root->right, re);
re.push_back(root->val);
}
vector<int> postorderTraversal(TreeNode* root) {
vector<int> re;
help(root, re);
return re;
}
};
方法2:非遞迴 相關文章
- LeetCode | 145. Binary Tree Postorder TraversalLeetCode
- Binary Tree Level Order Traversal [LEETCODE]LeetCode
- [leetcode]binary-tree-inorder-traversalLeetCode
- LeetCode | 144. Binary Tree Preorder TraversalLeetCode
- Leetcode 94. Binary Tree Inorder TraversalLeetCode
- Leetcode 144. Binary Tree Preorder TraversalLeetCode
- LeetCode 272 Closest Binary Tree Traversal II 解題思路LeetCode
- Binary-tree-level-order-traversal
- 102-Binary Tree Level Order Traversal
- 107-Binary Tree Level Order Traversal II
- 103. Binary Tree Zigzag Level Order Traversal
- Leetcode Binary Tree PathsLeetCode
- [LeetCode] 226. Invert Binary TreeLeetCode
- [LeetCode] 543. Diameter of Binary TreeLeetCode
- LeetCode 543. Diameter of Binary TreeLeetCode
- LeetCode545.Boundary-of-Binary-TreeLeetCode
- Leetcode 226. Invert Binary TreeLeetCode
- [leetcode]maximum-depth-of-binary-treeLeetCode
- LeetCode之Univalued Binary Tree(Kotlin)LeetCodeKotlin
- LeetCode之Binary Tree Pruning(Kotlin)LeetCodeKotlin
- LeetCode のminimum-depth-of-binary-treeLeetCode
- Leetcode 298 Binary Tree Longest Consecutive SequenceLeetCode
- LeetCode 104. Maximum Depth of Binary TreeLeetCode
- LeetCode 98. Validate Binary Search TreeLeetCode
- LeetCode#110.Balanced Binary Tree(Tree/Height/DFS/Recursion)LeetCode
- leetcode-124-Binary Tree Maximum Path SumLeetCode
- [LeetCode] 501. Find Mode in Binary Search TreeLeetCode
- [LeetCode] 671. Second Minimum Node In a Binary TreeLeetCode
- LeetCode 124. Binary Tree Maximum Path SumLeetCode
- [leetcode]convert-sorted-array-to-binary-search-treeLeetCode
- LeetCode之Construct String from Binary Tree(Kotlin)LeetCodeStructKotlin
- LeetCode 501. Find Mode in Binary Search TreeLeetCode
- [LeetCode] 2196. Create Binary Tree From DescriptionsLeetCode
- LeetCode C++ 968. Binary Tree Cameras【Tree/DFS】困難LeetCodeC++
- [LeetCode] 109. Convert Sorted List to Binary Search TreeLeetCode
- Java for LeetCode 109 Convert Sorted List to Binary Search TreeJavaLeetCode
- Traversals of binary tree
- LeetCode 545. Boundary of Binary Tree 二叉樹邊界LeetCode二叉樹