Leetcode 1617. Count Subtrees With Max Distance Between Cities
Given a tree (n ≤ 15), count for each d=1..n-1 how many connected node subsets (subtrees) have diameter exactly d — i.e., enumerate connected subsets and determine their maximum pairwise distance. The small n suggests bitmask enumeration with connectivity/longest-path checks.
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
0
Hello Interview Premium
Your account is free and you can post anonymously if you choose.