题解 | #二叉树的后序遍历#

二叉树的后序遍历

http://www.nowcoder.com/practice/1291064f4d5d4bdeaefbf0dd47d78541

```# class TreeNode:
#     def __init__(self, x):
#         self.val = x
#         self.left = None
#         self.right = None
#
# 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
#
# 
# @param root TreeNode类 
# @return int整型一维数组
#
import sys
sys.setrecursionlimit(1000000)
class Solution:
    def postorderTraversal(self , root: TreeNode) -> List[int]:
        res=[]
        def houxu(root):
            if not root:
                return None
            houxu(root.left)
            houxu(root.right)
            res.append(root.val)
        houxu(root)
        return res
##### 用递归的方式二叉树排序,easy
全部评论

相关推荐

点赞 收藏 评论
分享
牛客网
牛客企业服务