• + 0 comments

    instead of writing three condition for checking null like this:

    if((headA==NULL)&&(headB==NULL) return NULL; if((headA!=NULL)&&(headB==NULL)) return headA; if((headA == NULL)&&(headB!=NULL)) return headB;

    you can write:

    if(head1==nullptr) return head2;

    if(head2==nullptr) return head1;