LL list k append doubt


why is it giving runtime error :frowning:

Chahat, I have edited your code , now is not showing runtime error now,/…


Now, regarding the output, try to use some different approach, in your append function, For a hint, you can use a runner techique , where u will take 3 pointers, as :
node *slow=head;
node *fast=head;
node *oldhead=head;
and then
for(int i=0;i<k && fast->next!=NULL;i++)
{
fast=fast->next;
}
while(fast->next!=NULL && fast!=NULL)
{
fast=fast->next;
slow=slow->next;
}
using this determine new head,

thankyouu :slight_smile: