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