问题描述
https://leetcode.cn/problems/binary-tree-postorder-traversal/description/
解题思路
这个题和先序一样,没啥好说的。
代码
# Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution: def postorderTraversal(self, root: Optional[TreeNode]) -> List[int]: res = [] def dfs(root): if root is None: return dfs(root.left) dfs(root.right) res.append(root.val) dfs(root) return res
标签:遍历,val,self,dfs,145,right,二叉树,root,left From: https://www.cnblogs.com/bjfu-vth/p/17070996.html