On a $M\times N$ board, some cells are occupied. Find the size of the largest square of unoccupied cells.
We note that the size of an unoccupied cell is $1$ by definition. If its top, left, and top-left cells are all unoccupied, then the original cel is the bottom-right cell of a $2\times 2$ unoccupied square. If all the three adjacent cells are the bottom-right cells of a $2\times 2$ unoccupied squares, then the original cell is the bottom-right of a $3\times 3$ unoccupied square. If we set the size of an occupied cell as $0$, then we have the following recursion: $$size(x, y) = min(size(x-1, y), size(x, y-1), size(x-1, y-1))+1$$
where $x$ and $y$ are the indexes of the cell on the board. Accordingly, we can have the following algorithm: