Grokking Graph Algorithms for Coding Interviews
Ask Author
Back to course home

0% completed

Vote For New Content
Maximal Network Rank (medium)
On this page

Problem Statement

You are given an infrastructure with n cities and several roads connecting these cities. Each road connects two cities bidirectionally, represented by an array roads where roads[i] = [ai, bi] signifies a road between city ai and city bi.

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

Find the maximum network rank among all possible pairs of different cities.

Examples

Example 1:

  • Input: n = 4, `roads = [[0, 2], [0, 3], [1, 2], [1, 3]]

.....

.....

.....

Like the course? Get enrolled and start learning!

On this page