Connectivity after edge removals
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.
Implement
connectivity_after_removals(n: int, edges: list[list[int]], removals: list[list[int]]) → list[bool]Examples
in
[4,[[0,1],[1,2],[2,0],[2,3]],[[0,1],[2,3]]]out[true,false]What a strong answer looks like
State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
0:00 of about 35 min
solution.py
InputExpectedGot
[4,[[0,1],[1,2],[2,0],[2,3]],[[0,1],[2,3]]][true,false]not run yetsample