As reported: Flexport SDE-1 (Bengaluru, November 2025), virtual DSA round: a grid of open (
.) and permanently blocked (#) ports; a container moves between adjacent open ports in 8 directions, from any open port in the top row to any open port in the bottom row. Each day one port given by 1-indexed(row, column)becomes permanently blocked. Return the 1-indexed day on which the move first becomes impossible, or-1if it is still possible after all days. Constraints:2 ≤ m, n ≤ 10^4,4 ≤ m·n ≤ 2·10^5,1 ≤ days ≤ m·n.
You are given an m × n grid of '.' (open) and '#' (blocked), days, and blockages of length days, where blockages[d − 1] = [r, c] (1-indexed) is the port that becomes blocked on day d. A route exists if some open port in the top row connects to some open port in the bottom row through open ports, moving to any of the 8 neighbours. Before day 1 such a route exists.
Return the first day d after whose blockage no route exists, or -1 if a route still exists after all days blockages. Blocking an already blocked port changes nothing.
Example 1
grid = [". . # .",
". # # .",
". . # .",
"# # # ."]
days = 4, blockages = [[3, 2], [1, 1], [3, 4], [3, 1]]
Day 1 blocks (3,2), day 2 blocks (1,1): the right column still connects top to bottom.
Day 3 blocks (3,4): the only open bottom port (4,4) has no open neighbour left.
Output: 3
Example 2
grid = ["..", ".."], days = 2, blockages = [[1, 1], [2, 2]]
After day 2 only (1,2) and (2,1) are open — they touch diagonally.
Output: -1
Code runner format: three JSON values, one per line: grid (a list of row strings), days, blockages. Implement firstUnreachableDay(grid, days, blockages).