inorder_transversal.py 333 B

12345678910
  1. from typing import Optional, List
  2. from tree import TreeNode
  3. class Solution:
  4. def inorderTraversal(self, root: Optional[TreeNode]) -> List[int]:
  5. if root == None:
  6. return []
  7. left = self.inorderTraversal(root.left)
  8. right = self.inorderTraversal(root.right)
  9. return left + [root.val] + right