Algorithm · Square · Medium
Consider a grid with m rows and n columns, where rows are numbered from 0 to m - 1 and columns from 0 to n - 1. A subset of the cells is colored black, and their positions are listed in coordinates; every cell not in that list is white. Look at each $$2 \times 2$$ block of the grid and determine how many of its four cells are black. Produce an array ans with exactly 5 entries, where ans[i] (for each i with $$0 \le i \le 4$$) is the number of $$2 \times 2$$ blocks that…