Save the link, then rewire
transcript
You are reversing part of a chain. One wrong assignment can lose the rest of it. An interviewer watches for that exact mistake. One habit prevents it. Here it is.
First, find the node that comes after the group. Keep that node in a variable of its own. Only then change the link of the group.
Take seven nodes and reverse them in groups of three. Save the node after the first group. That is four. Turn the group round. Its new tail points at four. The second group turns round in the same way. Seven is alone in a short group, so it stays.
In the right order, you save the next node first. In the wrong order, you rewire first, and the rest is lost. The two lines differ only in their order. That is the whole bug.
The first group gives three, two, one. The second group gives six, five, four. The short group stays as seven.
Save the link you are about to overwrite. Then the rest of the chain stays reachable. Full breakdown in the lecture.