Trains the technique from
LeetCode 3195Find the Minimum Area to Cover All Ones IThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
A scanned page is held as a grid of cells. sheet[i][j] is 1 when that cell carries a mark and 0 when it is blank, and at least one cell carries a mark.
You want to crop the page down to a rectangle of whole cells whose sides run along the rows and columns, keeping every marked cell inside the crop. Blank cells inside the crop are fine.
Return the smallest number of cells such a crop can hold.
Example 1
The two marks sit on different rows and different columns, so the crop has to span both rows and both columns and takes in all four cells.
Example 2
The marks occupy rows 1 and 2 and columns 1 and 2, so a two by two crop holds them. The blank cell it picks up in the corner costs nothing.
Example 3
One mark on a single row, so the crop closes down to that one cell.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def minimum_area(sheet: list[list[int]]) -> int:public int minimumArea(int[][] sheet)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.