You are given two integers
m
andn
representing the dimensions of a 0-indexedm x n
grid.You are also given a 0-indexed 2D integer matrix
coordinates
, wherecoordinates[i] = [x, y]
indicates that the cell with coordinates[x, y]
is colored black. All cells in the grid that do not appear incoordinates
are white.A block is defined as a
2 x 2
submatrix of the grid. More formally, a block with cell[x, y]
as its top-left corner where0 <= x < m - 1
and0 <= y < n - 1
contains the coordinates[x, y]
,[x + 1, y]
,[x, y + 1]
, and[x + 1, y + 1]
.Return a 0-indexed integer array
arr
of size5
such thatarr[i]
is the number of blocks that contains exactlyi
*black cells*.
c++
1 | class Solution { |