Tap here to switch tabs
Problem
Submissions

Problem: Maximal Network Rank

med
30 min
Try to solve the Maximal Network Rank problem.

Statement

You are given an integer n representing the number of cities, labeled from 00 to n −1- 1, and an array roads where each roads[i] =[= [ a_i, b_i ]] indicates a bidirectional road between city a_i and city b_i.

The network rank of two distinct cities is the total number of directly connected roads to either city. If a road directly connects both cities, it is counted only once.

The maximal network rank is the maximum network rank across all pairs of distinct cities.

Return the maximal network rank of the infrastructure.

Constraints:

  • 2≤2 \leq n ≤100\leq 100

  • 0≤0 \leq roads.length ≤ext‘n‘⋅(ext‘n‘−1)2\leq \frac{ ext{`n`} \cdot ( ext{`n`} - 1)}{2}

  • roads[i].length =2= 2

  • 0≤0 \leq a_i, b_i ≤\leq n −1- 1

  • a_i ≠\neq b_i

  • Each pair of cities has at most one road connecting them.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Maximal Network Rank

med
30 min
Try to solve the Maximal Network Rank problem.

Statement

You are given an integer n representing the number of cities, labeled from 00 to n −1- 1, and an array roads where each roads[i] =[= [ a_i, b_i ]] indicates a bidirectional road between city a_i and city b_i.

The network rank of two distinct cities is the total number of directly connected roads to either city. If a road directly connects both cities, it is counted only once.

The maximal network rank is the maximum network rank across all pairs of distinct cities.

Return the maximal network rank of the infrastructure.

Constraints:

  • 2≤2 \leq n ≤100\leq 100

  • 0≤0 \leq roads.length ≤ext‘n‘⋅(ext‘n‘−1)2\leq \frac{ ext{`n`} \cdot ( ext{`n`} - 1)}{2}

  • roads[i].length =2= 2

  • 0≤0 \leq a_i, b_i ≤\leq n −1- 1

  • a_i ≠\neq b_i

  • Each pair of cities has at most one road connecting them.