Your Dashboard
Interview Coaching
Learn
System Design
ML System Design
Code
Behavioral
Salary Negotiation
Interview Guides
Search
⌘K
Get Premium
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.
All Regions
Comments
Hello Interview Premium
Your account is free and you can post anonymously if you choose.