Connectivity after edge removals

Write codeHard35 min

Your task

A network has n nodes (0..n-1) and a set of undirected edges [u, v]. Links fail one at a time in the order given by removals (each removal is one of the existing edges). After each removal, report whether the two endpoints of the just-removed link are still connected through the surviving network. Return a list of booleans, one per removal, in order.

Examples

connectivity_after_removals(n: int, edges: list[list[int]], removals: list[list[int]]) -> list[bool]
Example 1
Inputconnectivity_after_removals(4, [[0, 1], [1, 2], [2, 0], [2, 3]], [[0, 1], [2, 3]])
Output[True, False]