https://ide.codingblocks.com/s/161264 this code is not working?
Kth element from the inked list
Aman,can u pls tell why are u using recursive function in your code ??
to reverse the linked list and find the kth elements .i think ,this also a way to find kth element from the last of linked list without using length calculation.
Aman, basic approach you can follow up in the code is : You will use the runner technique in which you will have two node pointers, one as fast and other as slow, both pointing to the head of the linked list .
node *fast=head;
node *slow=head;
for(int jump=1;jump<=k;jump++)
{
fast=fast->next;
}
while(fast!=NULL)
{
fast=fast->next;
slow=slow->next;
}
cout<data;
}
Aman, since you arent replying anything, I am marking this doubt as resolved… you can reopen it if u face any issues…
not facing any issue