题解 | #二叉树的后序遍历#
二叉树的后序遍历
http://www.nowcoder.com/practice/1291064f4d5d4bdeaefbf0dd47d78541
class Solution:
def postorderTraversal(self , root: TreeNode) -> List[int]:
ans=[]
def postorder(root):
if not root: return
if root.left:
postorder(root.left)
if root.right:
postorder(root.right)
ans.append(root.val)
postorder(root)
return ans
题解-数据结构与算法 文章被收录于专栏
小菜鸟的题解