Python one line


  • 0
    A
    class Solution(object):
        def preorderTraversal(self, root):
            """
            :type root: TreeNode
            :rtype: List[int]
            """
    
            return [root.val]+ self.preorderTraversal(root.left) + self.preorderTraversal(root.right) if root else []
    

Log in to reply
 

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