题解 | #二叉树的后序遍历#
二叉树的后序遍历
http://www.nowcoder.com/practice/1291064f4d5d4bdeaefbf0dd47d78541
class Solution:
def postorderTraversal(self , root: TreeNode) -> List[int]:
# write code here
res = []
if root is not None:
if root.left is not None:
res += self.postorderTraversal(root.left)
if root.right is not None:
res += self.postorderTraversal(root.right)
res += [root.val]
return res