Help!!!Why go wrong?


  • 0
    Z
    class Solution(object):
        global relist
        relist=[]
        def preorderTraversal(self, root):
            """
            :type root: TreeNode
            :rtype: List[int]
            """
            if root==None:
                return []
            relist.append(root.val)
            self.preorderTraversal(root.left)
            self.preorderTraversal(root.right)
            return relist

  • 1

    Please read the FAQ for more details. You are using global variable and did not reset it in between test cases.


  • 0
    Z

    thx,very,very much


Log in to reply
 

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