Another logic for this question

can we iterate the fast and slow pointers in this way?
the fast pointer increments in k-1 steps
and the slow pointer increments by 1
when the fast pointer reaches end node or null, then the slow pointer will be pointing to the kth node from the end.

Dry run yourself with an example and check. You will understand well. Check for both odd and even length Linked List.
First, you can move the fast pointer K steps ahead. After that you can move the fast and slow pointer at the same rate of 1 step until Null is reached. At the end your slow pointer will be at the Kth node from end.

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.