Practice Count Pairs of Connectable Servers in a Weighted Tree Network
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Count Pairs of Connectable Servers in a Weighted Tree Network
Problem Statement
The edges [a, b, weight] form an undirected weighted tree of n servers numbered 0 through n - 1. Given signalSpeed, return one count per server c. Count unordered pairs of distinct other servers a and b for which the distances from c to a and from c to b are both divisible by signalSpeed, and the two paths starting at c share no edge. Count each pair once, equivalently using a < b.
Source: Count Pairs of Connectable Servers in a Weighted Tree Network on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
edges = [[0,1,1],[1,2,5],[2,3,13],[3,4,9],[4,5,2]], signalSpeed = 1
[0,4,6,6,4,0]
# Example 2
edges = [[0,6,3],[6,5,3],[0,3,1],[3,2,7],[3,1,6],[3,4,2]], signalSpeed = 3
[2,0,0,0,0,0,2]
Constraints
Related LeetCode Problems
Practice more problems similar to Count Pairs of Connectable Servers in a Weighted Tree Network.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.