<awangdev>221. Maximal Square_2.java
public int maximalSquare(char[][] matrix) {
        if (matrix == null || matrix.length == 0 || matrix[0] == null || matrix[0].length == 0) {
            return 0;
        }
        int m = matrix.length;
        int n = matrix[0].length;
        int[][] dp = new int[m][n];
        int maxLen = 0;
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < n; j++) {
                dp[i][j] = matrix[i][j] == '1' ? 1 : 0;
                maxLen = Math.max(dp[i][j], maxLen);
            }
        }

        for (int i = 1; i < m; i++) {
            for (int j = 1; j < n; j++) {
                if (matrix[i][j] == '1') {
                    dp[i][j] = Math.min(Math.min(dp[i - 1][j], dp[i][j - 1]), dp[i - 1][j - 1]) + 1;
                    maxLen = Math.max(dp[i][j], maxLen);
                }
            }
        }
        return maxLen * maxLen;
    }
public int sample_funcname ( char [ ] [ ] var_0 ) {
  if ( var_0 == null || var_0 . length == 0 || var_0 [ 0 ] == null || var_0 [ 0 ] . length == 0 ) {
    return 0 ;
  }
  int var_4 = var_0 . length ;
  int var_5 = var_0 [ 0 ] . length ;
  int [ ] [ ] var_6 = new int [ var_4 ] [ var_5 ] ;
  int var_7 = 0 ;
  for ( int var_8 = 0 ;
  var_8 < var_4 ;
  var_8 ++ ) {
    for ( int var_9 = 0 ;
    var_9 < var_5 ;
    var_9 ++ ) {
      var_6 [ var_8 ] [ var_9 ] = var_0 [ var_8 ] [ var_9 ] == '1' ? 1 : 0 ;
      var_7 = Math . max ( var_6 [ var_8 ] [ var_9 ] , var_7 ) ;
    }
  }
  for ( int var_8 = 1 ;
  var_8 < var_4 ;
  var_8 ++ ) {
    for ( int var_9 = 1 ;
    var_9 < var_5 ;
    var_9 ++ ) {
      if ( var_0 [ var_8 ] [ var_9 ] == '1' ) {
        var_6 [ var_8 ] [ var_9 ] = Math . min ( Math . min ( var_6 [ var_8 - 1 ] [ var_9 ] , var_6 [ var_8 ] [ var_9 - 1 ] ) , var_6 [ var_8 - 1 ] [ var_9 - 1 ] ) + 1 ;
        var_7 = Math . max ( var_6 [ var_8 ] [ var_9 ] , var_7 ) ;
      }
    }
  }
  return var_7 * var_7 ;
}
