You are viewing a single comment's thread. Return to all comments →
Solution in C
bool compare_lists(SinglyLinkedListNode* head1, SinglyLinkedListNode* head2) { SinglyLinkedListNode* curr1 = head1; SinglyLinkedListNode* curr2 = head2; if (head1 == NULL && head2 == NULL) {return true;} if (head1 == NULL || head2 == NULL) {return false;} while (curr1 != NULL && curr2 != NULL) { if (curr1->data != curr2->data) { return false; } curr1 = curr1->next; curr2 = curr2->next; } return (curr1 == NULL && curr2 == NULL);
}
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
}