Kindly let me know why it isn’t working…
Kth element from last in linked list doubt
You are using a wrong approach for kth reverse function in your code,
You will use two pointers fast and slow, and you will first jump upto k elements using fast pointer, after that you will move both pointers , fast as well as slow, and then you will print slow->data;
node fast=head;
for(int jump=1;jump<=k;jump++)
{
fast=fast->next;
}
nodeslow=head;
while(fast!=NULL)
{
fast=fast->next;
slow=slow->next;
}