SyntaxError: invalid syntax Last executed input: {}


  • 0
    W
    class Solution:
    # @param root, a tree node
    # @return a list of integers
    def preorderTraversal(self, root):
        result = []
        if root is None or root == '':
            return result
        
        realPreorderTraversal(root, result)
        return result
    def realPreorderTraversal(self, root, result)
        result.append(root.val)
        if root.left:
            self.realPreorderTraversal(root.left, result)
        if root.right:
            self.realPreorderTraversal(root.right, result)

Log in to reply
 

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