<qiyuangong>221_Maximal_Square_3.py
def maximalSquare( matrix):
    if matrix is None or len(matrix) == 0:
        return 0
    rows, cols, res, prev = len(matrix), len(matrix[0]), 0, 0
    dp = [0] * (cols + 1)
    for i in range(1, rows + 1):
        for j in range(1, cols + 1):
            temp = dp[j]
            if matrix[i - 1][j - 1] == '1':
                dp[j] = min(dp[j - 1], dp[j], prev) + 1
                res = max(res, dp[j])
            else:
                dp[j] = 0
            prev = temp
    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 , var_7 = len ( var_0 ) , len ( var_0 [ 0 ] ) , 0 , 0
    var_9 = [ 0 ] * ( var_5 + 1 )
    for var_11 in range ( 1 , var_4 + 1 ) :
        for var_12 in range ( 1 , var_5 + 1 ) :
            var_13 = var_9 [ var_12 ]
            if var_0 [ var_11 - 1 ] [ var_12 - 1 ] == '1' :
                var_9 [ var_12 ] = min ( var_9 [ var_12 - 1 ] , var_9 [ var_12 ] , var_7 ) + 1
                var_6 = max ( var_6 , var_9 [ var_12 ] )
            else :
                var_9 [ var_12 ] = 0
            var_7 = var_13
    return var_6 * var_6
