Problem 2277 · Hard

Closest Node to Path in Tree

Trace the start-to-end path with BFS parents, then take the path vertex nearest to the query node.

Open the interactive visualisation