Loading...
Loading...
Loading...
A floor plan of R rows and C columns marks free cells with 1 and blocked cells with 0. Find the largest square made only of free cells and print its area (side times side). Print 0 if there is no free cell.
Example
Input
3 4 1011 1111 0111
Output
4
A 2 by 2 square.
Try the problem first. Open one hint at a time.
Let size[r][c] be the side of the biggest square whose bottom-right corner is that cell.
A free cell is 1 plus the smallest of the cell above, the cell to the left and the cell diagonally above-left.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor