Delete nodes problem in linked list

#include
using namespace std;

class node{

public:
int data;
node*next = NULL;

node(int d){
    data = d;
    next = NULL;
}

};

void insert_at_tail(node*&head , int d){

if(head == NULL)
    {
        node*n = new node(d);
        head = n;
        return;
    }

node*n = new node(d);
node*temp = head;
while(temp->next != NULL){
    temp = temp->next;
}
temp->next = n;
n->next = NULL;

return;

}

void print_ll(node*head){

while(head != NULL){
    cout << head->data << " " ;
    head = head->next;

}

cout<<endl;

}

void checklist(node*head){

if(head == NULL)
    return;

node*temp1 = head;
node*temp2 = head->next;


while(temp2 != NULL){
    
    node *temp = temp1->next;

    if(temp1->data < temp2->data)
     {  
         if(temp1 == head){

             head = temp2;

         }
         delete temp1;
     }
     temp2 = temp2->next;
     temp1 = temp;
}

print_ll(head);

}

int main () {
node* head = NULL;
int n ;
cin >> n ;
while(n–){
int d;
cin >> d ;
insert_at_tail(head , d);
}

checklist(head);
return 0;

}

why isn’t it working?
ques - to delete nodes where the preceeding element is smaller than its right element

hi @aggarwal.naman21, let me check the question is not present in the hackerblock for me now

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.