• + 0 comments

    bool compare_lists(SinglyLinkedListNode* head1, SinglyLinkedListNode* head2) {

    int c=0; 
    
    while(head1!=NULL || head2!=NULL)
    {
        if(head1==NULL || head2==NULL)
        {
            return 0;
        }
        if(head1->data == head2->data){
    
            c=c+1;
        }
    
        else {
            c=0;
            break;
        }
        head1=head1->next;
        head2=head2->next;
    }
        if(c==0)
        {
            return 0;
        }
        else {
        return 1;
        }
    

    }