Merge two sorted linked lists

Sort by

recency

|

231 Discussions

|

  • + 0 comments

    This problem has several errors in the examples, it adds numbers that arent in the linked lists, removes other numbers that are, just in general seems like it was done by like the earliest attempt at AI, and then not checked at all for accuracy.

  • + 0 comments

    Typescript seems to be available, but it is not implemented.

  • + 0 comments

    C# solution after consulting geeksforgeeks when I got stuck

    static SinglyLinkedListNode mergeLists(SinglyLinkedListNode head1, SinglyLinkedListNode head2) {
            
            if (head1 is null) return head2;
            if (head2 is null) return head1;
            
            if (head1.data <= head2.data)
            {
                head1.next = mergeLists(head1.next, head2);
                return head1;
            }
            else
            {
              head2.next = mergeLists(head1, head2.next);
              return head2; 
            }
        }
    
  • + 0 comments

    C#, test case two fails. It seems there is 1 test case, for which the first linked list is 8 ints. The next set of ints for list 2 are unordered it seems. All of my other test cases pass.

  • + 0 comments

    the explanation part with sample had mistake ,

    Explanation

    The first linked list is: 1 -> 3 -> 7 ->NULL The second linked list is: 3->4->NULL Hence, the merged linked list is: 1->2->3->3->4->NULL where is the 7 gone from list 1 ?