Tree Walk
There are two people walking along a tree with $N$ nodes (numbered $1$ through $N$), each of them with speed 1 edge per second. The walk of the first person is described by a sequence of nodes $u_1, u_2, \dots, u_K$. This person appears in node $u_1$ at time $0$ and walks to node $u_2$ using the shortest **path**; then, immediately after reaching $u_2$, walks to node $u_3$ using the shortest pa
HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17
CodeSearch Tutor
Hints, not spoilers — it won’t hand over the full solution unless you insist.
Sign in to chat with the tutor and save your progress.
Sign in to start