[LeetCode]题解(python):094-Binary Tree Inorder Traversal

题目来源:

  https://leetcode.com/problems/binary-tree-inorder-traversal/


题意分析:

  中序遍历一个棵树。


题目思路:

  思路很简单,先遍历左子树,再遍历根节点,最后遍历右子树。


代码(Python):

  

class Solution(object):
    def inorderTraversal(self, root):
        """
        :type root: TreeNode
        :rtype: List[int]
        """
        if root == None:
            return []
        return self.inorderTraversal(root.left)+[root.val]+self.inorderTraversal(root.right)
View Code

转载请注明出处:http://www.cnblogs.com/chruny/p/5089004.html 

原文地址:https://www.cnblogs.com/chruny/p/5089004.html