2017.11.15
2017.11.16
"""
Definition of TreeNode:
class TreeNode:
def __init__(self, val):
self.val = val
self.left, self.right = None, None
"""
class Solution:
"""
@param: root: A Tree
@return: Postorder in ArrayList which contains node values.
"""
a = []
def postorderTraversal(self, root):
# write your code here
self.left(root)
return self.a
def left(self,root):
if root == None:
return
self.left(root.left)
self.right(root.right)
self.a.append(root.val)
def right(self,root):
if root == None:
return
self.left(root.left)
self.right(root.right)
self.a.append(root.val)
网友评论