← Back to companies
[ OK ] Loaded —
[ INFO ]
$ cd
$ ls -lt
01
02
03
04
05
$ ls -lt
01
02
03
04
05
user@intervues:~/$
You are given an empty m x n grid initially filled with water. We may perform an addLand operation where positions[i] = [ri, ci] turns the cell (ri, ci) into land. Return an array answer where answer[i] is the number of islands after the ith operation. An island is a maximal group of horizontally or vertically adjacent land cells.
` Input: m = 3, n = 3, positions = [[1,1], [2,1], [2,2], [1,2], [3,3], [3,2], [1,3], [2,3], [2,4]] Output: [1,2,2,3,3,3,4,5,6] Explanation:
Input: m = 1, n = 1, positions = [[1,1]] Output: [1]
1 <= m, n <= 501 <= positions.length <= 50positions[i].length == 21 <= ri <= m1 <= ci <= n