# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
#
# 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
#
#
# @param root TreeNode类
# @return int整型一维数组
#
class Solution:
def postorder(self,list:List[int],root:TreeNode):
if not root:
return
self.postorder(list,root.left)
self.postorder(list,root.right)
list.append(root.val)
def postorderTraversal(self , root: TreeNode) -> List[int]:
# write code here
list1=[]
self.postorder(list1,root)
return list1


京公网安备 11010502036488号