Skip to content

Commit 05917f6

Browse files
committed
create csharp/0145-binary-tree-postorder-traversal.cs
1 parent e984baa commit 05917f6

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
public class Solution {
2+
public IList<int> PostorderTraversal(TreeNode root)
3+
{
4+
var output = new List<int>();
5+
Traverse(output, root);
6+
return output;
7+
}
8+
9+
private void Traverse(List<int> output, TreeNode root)
10+
{
11+
if (root is null)
12+
{
13+
return;
14+
}
15+
16+
Traverse(output, root.left);
17+
Traverse(output, root.right);
18+
output.Add(root.val);
19+
}
20+
}

0 commit comments

Comments
 (0)