i m getting TLE
plz hepl me out with the code
k_append-LInkedList
Your code is not producing any output, thus I would recommend you to either return newHead from the append function, since the output is not produced.
but i have done cout ?shdnt it work?
plz help me out with the code
Eshanika, plz change your append function and use the below logic or approach of slow and fast headers in your code for the same,
node *append_nodes(node *head,int k)
{
node *slow=head;
node *fast=head;
node *oldhead=head;
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;
}
node *newHead=slow->next;
slow->next=NULL;
fast->next=oldhead;
return newHead;
}