• + 0 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;
        }