21/39
Part 4 of 7 · Cycles and meeting pointsLearn

Switch heads, and both pointers walk the same number of steps

Each pointer walks its own list, then the other one. Both have then walked the same number of nodes, so they arrive at the shared node together.

Predict

a has 5 nodes and b has 6, and they share the last 3. Each pointer walks its own list, then switches to the other's head. After how many steps do both stand on the shared 7?

Pick an answer above to see the rest