Skip to content

Commit 65fe47d

Browse files
authored
Create 9 October Postorder Traversal (#903)
2 parents c48139a + 8843915 commit 65fe47d

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

9 October Postorder Traversal

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
class Solution {
3+
void post(Node* root, vector<int>& ans){
4+
if (!root) return;
5+
post(root->left, ans);
6+
post(root->right, ans);
7+
ans.push_back(root->data);
8+
}
9+
public:
10+
vector<int> postOrder(Node* root) {
11+
// code here
12+
vector<int> ans;
13+
post(root, ans);
14+
return ans;
15+
}
16+
};

0 commit comments

Comments
 (0)