Leetcode 2737. Find the Closest Marked Node
Given an undirected tree (or graph) where nodes can be toggled "marked," support operations that mark/unmark nodes and queries that ask for the shortest distance from a given node to the nearest marked node. The challenge is to answer many dynamic distance queries efficiently (better than recomputing BFS from scratch), typically requiring multi-source shortest-path ideas or tree decomposition/centroid techniques.
Asked at:
DoorDash
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
0
Early March, 2026
DoorDash
Staff
Hello Interview Premium
Your account is free and you can post anonymously if you choose.