Wrong Answer in Error?

  • 0

    LeetCode is saying that my answer is [], when [1] is expected.

    But a print before return shows that I do return a ListNode, val 1.

    Any ideas what is happening here?

    code (the method is called by Solution.mergeKLists):

        if len(nodelist) == 0:
            return nodelist
        first = nodelist[0]
        if len(nodelist) <= 1:
            print first
            print first.val
            return first
        for node in nodelist[1:]:
            first = sort_merge_sorted_ListNodes(first, node)
        return first

Log in to reply

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