Number of Islands II

A satellite monitoring company is deploying sensor nodes across an m x n terrain grid. Initially all grid cells are water (inactive). Each position in the deployment list positions represents a coordinate [row, col] where a sensor node comes online, converting that cell from water to land (active).

A sensor network forms a connected monitoring zone when two active cells are adjacent horizontally or vertically (not diagonally). Your task is to return an array where the i-th element is the number of distinct monitoring zones (connected components) after the i-th sensor is deployed.

Two sensor deployments at the same coordinate are redundant; the cell is already active and the zone count does not change.

Examples
Input: [3,3,[[0,0],[0,1],[1,2],[2,1]]]
Output: [1,1,2,3]
Hints

Number of Islands II

A satellite monitoring company is deploying sensor nodes across an `m x n` terrain grid. Initially all grid cells are water (inactive). Each position in the deployment list `positions` represents a coordinate `[row, col]` where a sensor node comes online, converting that cell from water to land (active).