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].

/**
* Definition for a binary tree node.
* struct TreeNode {
*     int val;
*     TreeNode *left;
*     TreeNode *right;
*     TreeNode(int x) : val(x), left(NULL), right(NULL) {}
* };
*/
class Solution {
public:
void postorder(TreeNode* node,vector<int> &res){
if(!node){
return ;
}else{
postorder(node -> left,res);
postorder(node -> right,res);
res.push_back(node -> val);
}
}
vector<int> postorderTraversal(TreeNode* root) {
vector<int> vec;
postorder(root,vec);
return vec;
}
};

【LeetCode】145. Binary Tree Postorder Traversal 解题报告

2016-05-25 00:48:57

Binary Tree Postorder Traversal --leetcode

2014-12-16 10:10:12

LeetCode(145)Binary Tree Postorder Traversal

2014-01-16 04:01:50

106 Construct Binary Tree from Inorder and Postorder Traversal

2015-12-09 20:29:35

LeetCode 145：Binary Tree Postorder Traversal（后序遍历）

2015-05-23 01:38:46

Construct Binary Tree from Inorder and Postorder Traversal -- LeetCode

2014-04-24 09:02:17

Array-Construct Binary Tree from Inorder and Postorder Traversal

2017-12-17 00:04:22

#LeetCode# #C++# Binary Tree Postorder Traversal

2015-10-02 11:08:53

LeetCode145 Binary Tree Postorder Traversal Java题解（递归 迭代）

2015-07-09 10:34:20

Leetcode 145 Binary Tree Postorder Traversal（STL）

2018-06-25 20:45:49