You are viewing a single comment's thread. Return to all comments →
Solution in C
bool compare_lists(SinglyLinkedListNode* head1, SinglyLinkedListNode* head2) { SinglyLinkedListNode* local_head1 = head1; SinglyLinkedListNode* local_head2 = head2; while(local_head1 != NULL && local_head2 != NULL) { if(local_head1->data == local_head2->data) { local_head1 = local_head1->next; local_head2 = local_head2->next; } else { return 0; } if(local_head1 != NULL && local_head2 != NULL){ } else { if(local_head1 == NULL && local_head2 == NULL) return 1; else return 0; } } return 1; }
Seems like cookies are disabled on this browser, please enable them to open this website
Compare two linked lists
You are viewing a single comment's thread. Return to all comments →
Solution in C