How will it append

i am referring to the solution given in the editorial but i am unable to understand how will it swap the nos. can you give me an explanation for it?

we need to append the last k elements in the front so we take 2 pointers fast and slow. first we make fast k elements ahead of the slow. After that both of them are incremented till fast reaches NULL and when that happens slow would be pointing towards the last element in the linked list after k appendings. so we make necessary changes.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.