LeetCode 94. 二叉树的中序遍历 Python

给定一个二叉树,返回它的中序 遍历。

示例:

输入: [1,null,2,3]
   1
    \
     2
    /
   3

输出: [1,3,2] 
class Solution:
    def inorderTraversal(self, root):

        if root == None:
            return []
        res = []
        res += self.inorderTraversal(root.left)
        res.append(root.val)
        res += self.inorderTraversal(root.right)
        return res

你可能感兴趣的:(LeetCode)