Practice Maximal Network Rank
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
There is an infrastructure of n cities with some number of roads connecting these cities. Each roads[i] = [ai, bi] indicates that there is a bidirectional road between cities ai and bi. The network rank of two different cities is defined as the total number of directly connected roads to either city. If a road is directly connected to both cities, it is only counted once. The maximal network rank of the infrastructure is the maximum network rank of all pairs of different cities. Given the integer n and the array roads, return the maximal network rank of the entire infrastructure.
Source: Maximal Network Rank on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
n = 4, roads = [[0,1],[0,3],[1,2],[1,3]]
4
# Example 2
n = 5, roads = [[0,1],[0,3],[1,2],[1,3],[2,3],[2,4]]
5
# Example 3
n = 8, roads = [[0,1],[1,2],[2,3],[2,4],[5,6],[5,7]]
5
Constraints
Related LeetCode Problems
Practice more problems similar to Maximal Network Rank.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.