标签:etc mat log als ima ++ i++ des nim
Note:
For square, the minimum size of topleft and top and left decides the square of the result.
class Solution { public int maximalSquare(char[][] matrix) { if (matrix.length == 0) return 0; int result = 0; int[][] dp = new int[matrix.length + 1][matrix[0].length + 1]; for (int i = 1; i <= matrix.length; i++) { for (int j = 1; j <= matrix[0].length; 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; result = Math.max(dp[i][j], result); } } } return result*result; } }
标签:etc mat log als ima ++ i++ des nim
原文地址:http://www.cnblogs.com/shuashuashua/p/7542590.html