1-line Python


  • 0
    A
    class Solution(object):
        def preorderTraversal(self, root):
            return [] if not root else [root.val] + self.preorderTraversal(root.left) + self.preorderTraversal(root.right)
    

Log in to reply
 

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