• + 0 comments

    Nice solution. For the first three checks, you can simplify to:

    if (headA==NULL):
        return headB;
    if (headB==NULL):
        return headA;
    

    Because if they are both null, this will just return null which is what we want. But if only one is null, it will return the other.