Given a binary tree, return the postorder traversal of its nodes' values.
问题解决:
class Solution {
public:
void postOrder(TreeNode *root,vector<int>&vec){
if(root != NULL){
postOrder(root->left,vec);
postOrder(root->right,vec);
vec.push_back(root->val);
}
}
vector<int> postorderTraversal(TreeNode *root) {
vector<int>vec;
postOrder(root,vec);
return vec;
}
};