My one-line python solution.


  • 1
    T
    # Definition for a binary tree node.
    # class TreeNode:
    #     def __init__(self, x):
    #         self.val = x
    #         self.left = None
    #         self.right = None
    
    class Solution:
        # @param {TreeNode} root
        # @return {integer[]}
        def inorderTraversal(self, root):
            return [] if root is None else self.inorderTraversal(root.left) + [root.val] + self.inorderTraversal(root.right)

  • 0
    F

    what about the time costs of your solution?


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.