Given an MxN grid initialized with 0s, implement FillShape(lowerLeft, topRight, char) to fill a rectangle (shapes may overlap) and BringTop(r,c) to bring the whole rectangle that the char at (r,c) belongs to back on top.
Asked in the video screen stage.
Implement the following operations on a grid of characters:
FillShape(lowerLeft, topRight, char) fills the axis-aligned rectangle, inclusive of both corners.BringTop(r, c) finds the most recent rectangle covering cell (r, c) and moves that entire rectangle to the top of the stacking order.Return the final grid after all operations. Assume later fills overwrite earlier ones within overlapping regions, and BringTop only changes layering order, not rectangle boundaries.
def solve(m, n, operations):