You are viewing a single comment's thread. Return to all 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;
if(head1==nullptr) return head2;
if(head2==nullptr) return head1;
Seems like cookies are disabled on this browser, please enable them to open this website
Merge two sorted linked lists
You are viewing a single comment's thread. Return to all 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;