#3553
Minimum Weighted Subgraph With the Required Paths II
candidate master · 1445 · lc hard +32 · 49.7% accepted · 52 likes · top 37%
Description
Given a weighted undirected tree with n nodes and edges edges[i] = [ui, vi, wi], process queries [src1, src2, dest].
For each query, find the minimum-weight connected subtree that allows reaching dest from both src1 and src2.
Return an array of answers, one per query.
Code
1
2
3