๐ WAYPOINT LESSON
Checkpoint: relocation
โญโญ intermediateโณ 35 min read๐ Lesson 148 of 256
Minimum-move navigation with distance relaxation โ Q4's ceiling.
relocate is BFS-lite: seed the start with distance 0, relax neighbors
in passes until nothing changes, read the target's distance โ or -1
when the fill never reaches it. It fuses navigation, guards, and the
sentinel into one method, which is why Q4 sometimes asks for exactly
this. If your first version moved into already-shorter cells forever,
the relaxation condition was missing dist[nr][nc] > dist[r][c] + 1.