Leetcode 3067. Count Pairs of Connectable Servers in a Weighted Tree Network
For each node c in a weighted tree, count unordered pairs of distinct servers (a,b) (neither equal to c) such that the distances from c to a and to b are each divisible by signalSpeed and the paths from c to a and b go into different incident branches (edge-disjoint). The core task is, for every node, to compute distance residues (mod signalSpeed) of nodes in each neighboring subtree and sum cross-subtree products of nodes with residue 0 to get the pair counts.
Asked at:
Nvidia
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
Mid December, 2025
Nvidia
Mid-level
Basically a directed graph problem where the you are given nodes and a number of nodes that are down. All downstream nodes are also affected by the outage. You need to count the total number of nodes that are down. You basically just make an adjacency list and then traverse starting from all the down source nodes and traverse, keeping a visited set and returning the length of the visited set.
Comments
Hello Interview Premium
Your account is free and you can post anonymously if you choose.