My C# solution using recursive loop

  • 0
    public ListNode MergeTwoLists(ListNode l1, ListNode l2) {
            if (l1 == null)
                return l2;
            if (l2 == null)
                return l1;
            ListNode node, another;
            if (l1.val <= l2.val)
                node = l1;
                another = l2;
                node = l2;
                another = l1;
   = MergeTwoLists(, another);
            return node;

Log in to reply

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