We are given a linked list (like [2 → 4 → 7 → 8])

and a number k.

We must return the k-th node from the end.

Example:


🎯 One-Pass Solution (Two Runners Trick)

Key Hack / Initial Trick 🧠

👉 Start Runner A k steps ahead of Runner B.

Why?

Because then when Runner A reaches the end of the list,

Runner B will automatically be k steps behind → exactly at the node we want. ✅


Step-by-Step

  1. Put Runner A and Runner B at the head (start of the list).

  2. Move Runner A forward k steps.

  3. Move both runners forward together, one step at a time.

  4. When Runner A reaches the end →

    Runner B is standing at the k-th node from the end. 🎉