• + 0 comments

    nice solution.

    The latter part of the code can be slightly shortened:

    if(headA.data >= headB.data) {
            Node temp = headB;
            headB = headB.next;
            temp.next = headA;
            headA = temp;
        }
        headA.next = mergeLists(headA.next,headB);
        return headA;