每日一题力扣145 二叉树的后序遍历

给定一个二叉树,返回它的 后序 遍历。

示例:

输入: [1,null,2,3]
1

2
/
3

输出: [3,2,1]

来源:力扣(LeetCode)
链接:https://leetcode-cn.com/problems/binary-tree-postorder-traversal
著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。

class Solution:
    def postorderTraversal(self, root: TreeNode) -> List[int]:
        def outorder(t):
            if not t:
                return
            outorder(t.left)
            outorder(t.right)
            res.append(t.val)
        res=[]
        outorder(root)
        return res
原文地址:https://www.cnblogs.com/liuxiangyan/p/14658701.html