recursive Python 1-line solution


  • 0
    J

    def preorderTraversal(self, root):
    return [root.val] + self.preorderTraversal(root.left) + self.preorderTraversal(root.right) if root is not None else []


Log in to reply
 

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