Search
⌘K

Leetcode 3553. Minimum Weighted Subgraph With the Required Paths II

Given a weighted tree and many queries of three distinct nodes (src1, src2, dest), return the minimum total weight of a connected subtree that contains all three nodes — which equals half the sum of their three pairwise distances. Precompute distances (e.g., via root-based distances + LCA) to answer each query in O(1).


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.