i am unable to find the error.
Please help with the error
@akshatkaush
your reverse function is not correct
not passing even sample testcases
look at this fucntion below
you have to do like that
node* reverse(node* head, int k) {
if(head==NULL)return NULL;
node* curr=head;
node* prev=NULL;
node* nxt=curr->next;
int cnt=0;
while(cnt<k&&curr){
curr->next=prev;
prev=curr;
curr=nxt;
if(curr)nxt=curr->next;
cnt++;
}
head->next=reverse(curr,k);
return prev;
}
your approach is similar to this but there are some mistakes and dont handle corner cases
correct this and it ll pass all your test casess 