please post the solution of given code
Need the solution
Harshit, the basic approach you can follow up here is that, you can take two node pointers, one as the slow and other as fast, both pointing at the head position of the linked list,
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;
This is the basic approach you can follow up…You can also go through the hint video which is given in the online section as well.
Since you arent replying anything, I am marking this doubt as resolved… You can reopen it if u still face any issues…