<qiyuangong>221_Maximal_Square_2.py
def maximalSquare( matrix):
    if matrix is None or len(matrix) == 0:
        return 0
    rows, cols, res = len(matrix), len(matrix[0]), 0
    dp = [[0] * (cols + 1) for _ in range(rows + 1)]
    for i in range(1, rows + 1):
        for j in range(1, cols + 1):
            if matrix[i - 1][j - 1] == '1':
                dp[i][j] = min(dp[i][j - 1], dp[i - 1][j], dp[i - 1][j - 1]) + 1
                res = max(res, dp[i][j])
    return res * res
def sample_funcname ( var_0 ) :
    if var_0 is None or len ( var_0 ) == 0 :
        return 0
    var_4 , var_5 , var_6 = len ( var_0 ) , len ( var_0 [ 0 ] ) , 0
    var_10 = [ [ 0 ] * ( var_5 + 1 ) for var_8 in range ( var_4 + 1 ) ]
    for var_11 in range ( 1 , var_4 + 1 ) :
        for var_12 in range ( 1 , var_5 + 1 ) :
            if var_0 [ var_11 - 1 ] [ var_12 - 1 ] == '1' :
                var_10 [ var_11 ] [ var_12 ] = min ( var_10 [ var_11 ] [ var_12 - 1 ] , var_10 [ var_11 - 1 ] [ var_12 ] , var_10 [ var_11 - 1 ] [ var_12 - 1 ] ) + 1
                var_6 = max ( var_6 , var_10 [ var_11 ] [ var_12 ] )
    return var_6 * var_6
