• + 1 comment

    First check (headA == NULL && headB == NULL) is not necessary because the following two will handle it.

    • + 2 comments

      No, you need this. The first one handles if they are both NULL. The second handles if only one is NULL. If we ask about if one is NULL, without knowing about the second, we would need yet another if statement inside of it.

      • + 0 comments

        I disagree. If both are NULL, then

        if (headA == NULL)
            return headB;
        

        will trigger and return NULL since that is what headB equals to. And we did expect NULL, so the case of two NULLs is indeed redundant.

      • + 0 comments

        it will handle it because if both are null when you check the first list it runs true and return second which is null itself so null is returned