Search
⌘K

Leetcode 2959. Number of Possible Sets of Closing Branches

Count how many subsets of branches can be closed so that every pair of remaining branches has weighted shortest-path distance ≤ maxDistance (empty or single-node sets count). Algorithmically this requires computing all-pairs shortest paths and then counting subsets of nodes whose pairwise distances all meet the threshold — equivalently counting cliques in the threshold graph defined by dist(u,v) ≤ maxDistance.


Question Timeline

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

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