Search
⌘K

Leetcode 2277. Closest Node to Path in Tree

Given a tree and many queries specifying a path between two nodes, for each query return which candidate node (from a given set) is closest to any vertex along the simple path (or the distance to that nearest node). The core challenge is computing nearest-to-path distances efficiently across many queries by preprocessing tree distances/path structure to avoid walking the path per query.


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Comments

Your account is free and you can post anonymously if you choose.