Novo curso: Como conseguir vagas remotas em empresas que pagam $120k+/ano
NaGringa
CodingMid-level

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.

Empresas em que apareceu
NVIDIANVIDIA
Contextos reais

Onde essa pergunta já apareceu

Use esses exemplos para entender em que contexto ela costuma cair e adaptar sua prática.

NVIDIAmiddez. de 2025

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.

Anexos públicos

Materiais associados

Nenhum anexo público associado a esta pergunta.

Próximo passo

Depois de treinar essa pergunta, vale abrir outras do mesmo tipo e da mesma senioridade para comparar padrões de resposta.

Isso ajuda a sair da memorização de uma resposta só e entrar em repertório real de entrevista.

Continue a preparação com o banco completo

No app você encontra perguntas parecidas, compara empresas e aprofunda essa busca com mais filtros.