rects where rects[i] = [r1, c1, r2, c2] is a rectangle with top-left corner (r1, c1) and bottom-right corner (r2, c2), inclusive. Each rectangle adds one layer of paint: every cell (r, c) with r1 ≤ r ≤ r2 and c1 ≤ c ≤ c2 goes up by 1.
Return the grid after all rectangles have been applied.n=3, rects=[[0, 0, 1, 2], [1, 1, 2, 1]] → [[1, 1, 1], [1, 2, 1], [0, 1, 0]]
The first rectangle covers the top two rows, the second the middle column in rows 1 and 2. Cell (1, 1) is painted twice.
n=2, rects=[[1, 0, 1, 0], [1, 0, 1, 0], [0, 1, 0, 1]] → [[0, 1], [2, 0]]
Cell (1, 0) is painted twice, cell (0, 1) once.
n=1, rects=[[0, 0, 0, 0]] → [[1]]
n=3, rects=[[0, 0, 1, 2], [1, 1, 2, 1]]
[[1, 1, 1], [1, 2, 1], [0, 1, 0]]
Run checks the first 3 tests in your browser. Submit checks all 68 tests on the server, hidden ones included.