Find all zones, the maximal groups of mutually reachable cities, in a directed graph.
Unlock detailed company stats for this questionUpgrade
connections[i] = [a, b] is a one-way connection from city a to city b. A zone is a maximal group of cities where for any two cities u and v in the zone there is a directed path from u to v and from v to u. Find all zones.
Test case: connections = [(0,1),(1,2),(2,3),(3,0),(3,4),(4,5),(5,4),(6,5),(6,7)], n = 8 returns [[0,1,2,3],[4,5],[6],[7]].
Expect follow-ups like
- Find all trapped zones: zones with at least one incoming connection from another zone and no outgoing connections to any other zone.
Community answers
No answers contributed by the community yet.


