BudiBadu Logo
00:00

Skyway Signal Cluster

Graph Easy 0 views

The aerial transit authority manages a set of skyway decks that float above the city. Each deck is assigned a number from 0 to n - 1, and maintenance crews record every connector that lets passengers move between two decks. When the control center sends a broadcast from one deck, any deck connected by a skyway segment can pass the message along to neighboring decks. The authority wants to measure how large the broadcast cluster becomes once the signal spreads as far as possible.

Implement a function that accepts the number of decks n, the list of connectors, and the starting deck start. Each connector is written as [x, y], representing a skyway that links decks x and y in both directions. The list may contain repeated entries or connectors that point from a deck to itself; such data irregularities should not change the final answer. Decks that are not connected to the starting deck remain silent, even if they connect to each other somewhere else.

The function must return the size of the connected cluster that includes start. Count every unique deck that can be reached by traversing one connector at a time, including the starting deck. If start is isolated, the result is 1. If the network is fully connected, the result is n. Ensure your logic handles branching networks, loops that revisit the same deck, and lists with no connectors at all. The goal is to quantify the reach of the broadcast without double-counting any deck that the message can visit by any path.

Example 1:

Input: n = 5, connectors = [[0,1],[1,2],[2,3],[3,4]], start = 2
Output: 5
Explanation: Every deck is connected through the chain, so the broadcast covers all decks.

Example 2:

Input: n = 6, connectors = [[0,1],[2,3],[3,4],[4,2]], start = 3
Output: 3
Explanation: The cluster includes decks 2, 3, and 4; the other decks are unreachable.

Example 3:

Input: n = 4, connectors = [], start = 1
Output: 1
Explanation: With no connectors, the broadcast remains at the starting deck.

Related Problems

No related problems found

Comments (0)

Join the Discussion

Share your thoughts, ask questions, or help others with this problem.

BudiBadu Logo

Skyway Signal Cluster

Graph Easy 0 views

The aerial transit authority manages a set of skyway decks that float above the city. Each deck is assigned a number from 0 to n - 1, and maintenance crews record every connector that lets passengers move between two decks. When the control center sends a broadcast from one deck, any deck connected by a skyway segment can pass the message along to neighboring decks. The authority wants to measure how large the broadcast cluster becomes once the signal spreads as far as possible.

Implement a function that accepts the number of decks n, the list of connectors, and the starting deck start. Each connector is written as [x, y], representing a skyway that links decks x and y in both directions. The list may contain repeated entries or connectors that point from a deck to itself; such data irregularities should not change the final answer. Decks that are not connected to the starting deck remain silent, even if they connect to each other somewhere else.

The function must return the size of the connected cluster that includes start. Count every unique deck that can be reached by traversing one connector at a time, including the starting deck. If start is isolated, the result is 1. If the network is fully connected, the result is n. Ensure your logic handles branching networks, loops that revisit the same deck, and lists with no connectors at all. The goal is to quantify the reach of the broadcast without double-counting any deck that the message can visit by any path.

Example 1:

Input: n = 5, connectors = [[0,1],[1,2],[2,3],[3,4]], start = 2
Output: 5
Explanation: Every deck is connected through the chain, so the broadcast covers all decks.

Example 2:

Input: n = 6, connectors = [[0,1],[2,3],[3,4],[4,2]], start = 3
Output: 3
Explanation: The cluster includes decks 2, 3, and 4; the other decks are unreachable.

Example 3:

Input: n = 4, connectors = [], start = 1
Output: 1
Explanation: With no connectors, the broadcast remains at the starting deck.

00:00
Loading editor...
Test Results

Run your code to see test results

Click the Submit button to execute your solution

Related Problems

No related problems found

Comments (0)

Join the Discussion

Share your thoughts, ask questions, or help others with this problem.