this code gives segmentation fault.
Kindly comment out the logical/syntactical errors
Ll-k reverse problem
check this one
Hello @mkidwai74 you are taking input by checking while(d!=-1)
but that is not the case here you have to take inout for n nodes which is given in the input.
and also while doing k reverese:
you are doing it by recursively and iteratively in the both way:
it should be like this:
node* llkreverse(node*&head,int k)
{
node*prev=NULL;
node*curr=head;
int count=0;
while(curr!=NULL)
{ node*nex=curr->next;
curr->next=prev;
prev=curr;
curr=nex;
// nex=curr->next;/
count++;
}
// if(nex!=NULL)
// {
// head->next=llkreverse(nex,k);
// }
return prev;
}
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.