node* kelement(node* head,int k)
{
if(head==NULL || head->next==NULL)
return head;
int i=1;
node* fast=head;
node* slow=head;
while(i<=k)
{
fast=fast->next;
}
while(fast->next!=NULL)
{
slow=slow->next;
}
return slow;
}
For calculating kth node from end of linked list,what is wrong in this function?