import java.util.*;
public class Solution { /** * 最大正方形 * @param matrix char字符型二维数组 * @return int整型 */ public int solve (char[][] matrix) { // write code here if(matrix == null||matrix.length==0){return 0;} int m = matrix.length; int n = matrix[0].length; int res = 0; int[][] dp = new int[m + 1][n + 1]; for(int i = 1; i <= m; ++i){ for(int j = 1; j <= n; ++j){ if(matrix[i - 1][j - 1] == '1'){ dp[i][j] = Math.min(Math.min(dp[i - 1][j], dp[i][j - 1]), dp[i - 1][j - 1]) + 1; res = Math.max(res, dp[i][j]); } } } return res * res; } }