Problem · Array
Maximal Square
Learn this problemProblem statement
Given a matrix of characters '0' and '1', return the area of the largest square containing only '1' cells.
Function
maximalSquare(matrix: char[][]) → intExamples
Example 1
matrix = [["1","0","1","0","0"],["1","0","1","1","1"],["1","1","1","1","1"],["1","0","0","1","0"]]return = 4The largest all-one square has side length 2.
Example 2
matrix = [["0"]]return = 0