<qiyuangong>132_Palindrome_Partitioning_II_1.py
def minCut( s):
    if len(s) <= 1:
        return 0
    ls = len(s)
    d = [0] * ls
    pal = [[False] * ls for _ in range(ls)]
    for i in range(ls - 1, -1, -1):
        d[i] = ls - i - 1
        for j in range(i, ls):
            if s[i] == s[j] and (j - i < 2 or pal[i + 1][j - 1]):
                pal[i][j] = True
                if j == ls - 1:
                    d[i] = 0
                elif d[j + 1] + 1 < d[i]:
                    d[i] = d[j + 1] + 1
    return d[0]
def sample_funcname ( var_0 ) :
    if len ( var_0 ) <= 1 :
        return 0
    var_4 = len ( var_0 )
    var_5 = [ 0 ] * var_4
    var_9 = [ [ False ] * var_4 for var_7 in range ( var_4 ) ]
    for var_10 in range ( var_4 - 1 , - 1 , - 1 ) :
        var_5 [ var_10 ] = var_4 - var_10 - 1
        for var_11 in range ( var_10 , var_4 ) :
            if var_0 [ var_10 ] == var_0 [ var_11 ] and ( var_11 - var_10 < 2 or var_9 [ var_10 + 1 ] [ var_11 - 1 ] ) :
                var_9 [ var_10 ] [ var_11 ] = True
                if var_11 == var_4 - 1 :
                    var_5 [ var_10 ] = 0
                elif var_5 [ var_11 + 1 ] + 1 < var_5 [ var_10 ] :
                    var_5 [ var_10 ] = var_5 [ var_11 + 1 ] + 1
    return var_5 [ 0 ]
