What's wrong with my code


  • 0
    T
    class Solution:
    # @param {TreeNode} root
    # @return {integer[]}
    def preorderTraversal(self, root ,a=[]):
        if root:
            a.append(root.val)
            self.preorderTraversal(root.left,a)
            self.preorderTraversal(root.right,a)
        return a

Log in to reply
 

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