305. Number of Islands II

Problem

Given a 2D grid of water, process a list of land additions and return the number of islands after each addition.

You are given an empty 2D grid of size m x n. You receive a list of positions where land is added ('1'). After each addition, return the number of islands in the grid.

An island is a group of 1s (land) connected vertically or horizontally.

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

305. Number of Islands II

Given a 2D grid of water, process a list of land additions and return the number of islands after each addition.