Skip to content

Commit 4b3c581

Browse files
author
Parth Shah
authored
#145 Recursive Approach
1 parent 1873f73 commit 4b3c581

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Definition for a binary tree node.
2+
# class TreeNode(object):
3+
# def __init__(self, x):
4+
# self.val = x
5+
# self.left = None
6+
# self.right = None
7+
8+
class Solution(object):
9+
def postorderTraversal(self, root):
10+
"""
11+
:type root: TreeNode
12+
:rtype: List[int]
13+
"""
14+
result = []
15+
def postorder(root,result):
16+
if not root:
17+
return
18+
postorder(root.left,result)
19+
postorder(root.right,result)
20+
result.append(root.val)
21+
postorder(root,result)
22+
return result

0 commit comments

Comments
 (0)