Advertisement
Guest User

Untitled

a guest
Sep 29th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. # Definition for a binary tree node.
  2. class TreeNode(object):
  3. def __init__(self, x):
  4. self.val = x
  5. self.left = None
  6. self.right = None
  7.  
  8. class Solution(object):
  9. def inorderTraversal(self, root):
  10. """
  11. :type root: TreeNode
  12. :rtype: List[int]
  13. """
  14.  
  15. if not root:
  16. return([])
  17.  
  18. out = []
  19.  
  20. l = self.inorderTraversal(root.left)
  21. if l: out += l
  22. out += [root.val]
  23. r = self.inorderTraversal(root.right)
  24. if r: out += r
  25. return(out)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement