Skip to content
Discussion options

You must be logged in to vote

We need to handle two types of queries on a power grid where stations can go offline, and I need to find the smallest operational station in the same connected component.

Approach

  1. Union-Find for Connectivity: First, I'll use Union-Find to group stations into connected components based on the given connections.

  2. Track Operational Status: Maintain an array to track which stations are operational (online).

  3. Component Minimum Tracking: For each component, track the smallest operational station ID. When stations go offline, I need to efficiently update this minimum.

  4. Query Processing:

    • For type 1 queries: If station is online, return itself; otherwise return the minimum operational statio…

Replies: 1 comment 2 replies

Comment options

mah-shamim
Nov 6, 2025
Maintainer Author

You must be logged in to vote
2 replies
@basharul-siddike
Comment options

@mah-shamim
Comment options

mah-shamim Nov 6, 2025
Maintainer Author

Answer selected by basharul-siddike
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
question Further information is requested medium Difficulty
2 participants