Wrong Answer in Error?


  • 0
    H

    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
    
    ![0_1481436807500_merge_k_sorted_lists.one_case_issue.png](/uploads/files/1481436799997-merge_k_sorted_lists.one_case_issue.png)

Log in to reply
 

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