图片说明

/**
 * 最大正方形
 * @param matrix char字符型二维数组 
 * @return int整型
 */
function solve( matrix ) {
    // write code here
    let row = matrix.length
    let column = matrix[0].length
    let maxSquare = 0
    for(let i=0;i<row;i++){
        for(let j=0;j<column;j++){
            if(matrix[i][j] == 1 && i!=0 && j!=0){
                matrix[i][j] = Math.min(matrix[i-1][j],matrix[i][j-1],matrix[i-1][j-1]) + 1
            }
            maxSquare = Math.max(maxSquare,matrix[i][j])
        }
    }
    return maxSquare * maxSquare
}
module.exports = {
    solve : solve
};