Given a grid of bricks and a list of hits, return how many bricks fall after each hit. DSU is used in reverse: restore bricks from the last hit to the first while maintaining connectivity to the roof.
grid = brick matrix, hits = cells removed one by one
number of bricks falling after each hit
Example 1:
Input:
grid = [[1,0,0,0],[1,1,1,0]] hits = [[1,0]]
Output:
[2]
Explanation:
Removing the brick at (1,0) causes two additional bricks to fall.
Example 2:
Input:
grid = [[1,0,0,0],[1,1,1,0]] hits = [[1,0],[1,1]]
Output:
[2,0]
Explanation:
The first hit drops two bricks; the second hit drops none.
Example 3:
Input:
grid = [[1]] hits = [[0,0]]
Output:
[0]
Explanation:
A single brick removed directly does not cause any extra bricks to fall.