12345678910111213 |
- class TreeNode:
- def __init__(self, val=0, left=None, right=None):
- self.val = val
- self.left = left
- self.right = right
- class Solution:
- def inorderTraversal(self, root: Optional[TreeNode]) -> List[int]:
- if root == None:
- return []
- left = self.inorderTraversal(root.left)
- right = self.inorderTraversal(root.right)
- return left + [root.val] + right
|