Two cursors, one walk
transcript
Remove the k-th message from the end. You cannot see the length. Two cursors solve it in one walk. A second walk to count the length is not needed.
The thread has five messages, and k is two. The lead starts at the second node. The trail starts at the head. The gap between them is k minus one nodes.
Move both cursors by one node each time. Stop when the lead is on the last node. The gap between them never changes. Both cursors end on the right nodes together.
The trail stops on forty. That is the second newest message. It took one walk, not two. To remove it, you need the node before.
A common slip is to start the lead at k. The gap is one too small. Start it at k minus one. Then the trail stops on the right message.
Start on a placeholder. Then the head works too. Full breakdown in the lecture.