Can you tell my mistake?

hello @vageesha

check now->

@vageesha

node* prev=head;
    while(j<=length(head)-1)
    {
        prev=prev->next;
        j++;
    }
    delete tail;
    prev->next=NULL;

consider this list
1->2->3
length = 3 , j=1,prev is pointer to 1.
now as per while loop condition we need to iterate legnth-1 times i,e 2 times.
after first iteration -> j=2, prev will point to 2
after second iteration-> j=3 ,prev will point to 3
clearly we are doing one extra iteration that why i change <= with <

Okay, thankyou, I got it.

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.