<span>leetcode-94 Binary Tree Inorder Traversal</span>
Given the root of a binary tree, return the inorder traversal of its nodes' values.
示例:
Input: root = [1,null,2,3] Output: [1,3,2]
本题就是一个简单的中序遍历二叉树
1 # Definition for a binary tree node. 2 # class TreeNode: 3 # def __init__(self, val=0, left=None, right=None): 4 # self.val = val 5 # self.left = left 6 # self.right = right 7 class Solution: 8 def inOrder(self, root, arr): 9 if root != None: 10 self.inOrder(root.left, arr) 11 arr.append(root.val) 12 self.inOrder(root.right, arr) 13 return arr 14 def inorderTraversal(self, root: TreeNode) -> List[int]: 15 arr = [] 16 arr = self.inOrder(root, arr) 17 return arr