I can't figure out what's wrong with my python code

  • 0

    I get a lot of runtime errors. I get so frustrated. So finally, I just add the following code:

    class Solution:
        # @param root, a tree node
        # @return an integer
        def maxPathSum(self, root):
            if root == None: 
                return 0
            def dfs(node):
                if node == None: return
                if node.left:
                if node.right:

    It still gives me runtime error. I would expect at least a wrong answer. Anyone knows why?

  • 0

    The code seems fine. Need more details.
    And you don't need the line if node == None: return in dfs

Log in to reply

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