题解 | #二叉树的后序遍历#
二叉树的后序遍历
http://www.nowcoder.com/practice/32af374b322342b68460e6fd2641dd1b
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
#
#
# @param root TreeNode类
# @return int整型一维数组
#
class Solution:
# 后序遍历指左、右、根
def postorderTraversal(self , root ):
# write code here
def dfs(cur):
if cur is None:
return
dfs(cur.left)
dfs(cur.right)
res.append(cur.val)
res = []
dfs(root)
return res