Company: Schrodinger_30may
Difficulty: medium
A system contains pods numbered from 1 to pods , distributed across multiple geographical regions. The pods are interconnected by n links represented in an array called connections . Pods belong to the same region if they are connected directly or indirectly. Each pod writes critical data to its database connection. If a pod loses its connection: It forwards data to the active pod with the smallest ID in the same region. If no active pods remain in the region, the data is not written and an error is logged. Process q queries of two types: Data-sending query: "1 pod_id" Database-connection-failure query: "2 pod_id" Return an integer array where, for each data-sending query, it contains the ID of the pod that writes the data to the database. If no active pods remain in the region, it should store -1. Example Suppose pods = 3 , n = 2 , connections = [[1, 2], [2, 3]] , q = 5 , and queries = [[2, 2], [1, 2], [2, 1], [2, 3], [1, 1]] . Query Pod Losing Connection Result Remarks 2, 2 2 - 1, 2