Skip to content

Commit c0b090f

Browse files
authored
145. Binary tree PostOrder Traversal
1 parent 911e13d commit c0b090f

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

145. Binary tree PostOrder Traversal

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
public:
2+
void postorder(TreeNode* root,vector<int> &ans){
3+
if(root == NULL) return;
4+
postorder(root->left,ans);
5+
postorder(root->right,ans);
6+
ans.push_back(root->val);
7+
}
8+
vector<int> postorderTraversal(TreeNode* root) {
9+
vector<int>ans;
10+
postorder(root,ans);
11+
return ans;
12+
}
13+
};

0 commit comments

Comments
 (0)