comefrom: <doocs>0132.Palindrome Partitioning II_1.py
code: def minCut( s: str) -> int:
      n = len(s)
      dp1 = [[False] * n for _ in range(n)]
      for i in range(n - 1, -1, -1):
          for j in range(i, n):
              dp1[i][j] = s[i] == s[j] and (j - 1 < 3 or dp1[i + 1][j - 1])
      dp2 = [0] * n
      for i in range(n):
          if not dp1[0][i]:
              dp2[i] = i
              for j in range(1, i + 1):
                  if dp1[j][i]:
                      dp2[i] = min(dp2[i], dp2[j - 1] + 1)
      return dp2[-1]
masked: def sample_funcname ( var_0 : str ) -> int :
      var_1 = len ( var_0 )
      var_3 = [ [ False ] * var_1 for var_2 in range ( var_1 ) ]
      for var_4 in range ( var_1 - 1 , - 1 , - 1 ) :
          for var_5 in range ( var_4 , var_1 ) :
              var_3 [ var_4 ] [ var_5 ] = var_0 [ var_4 ] == var_0 [ var_5 ] and ( var_5 - 1 < 3 or var_3 [ var_4 + 1 ] [ var_5 - 1 ] )
      var_6 = [ 0 ] * var_1
      for var_4 in range ( var_1 ) :
          if not var_3 [ 0 ] [ var_4 ] :
              var_6 [ var_4 ] = var_4
              for var_5 in range ( 1 , var_4 + 1 ) :
                  if var_3 [ var_5 ] [ var_4 ] :
                      var_6 [ var_4 ] = min ( var_6 [ var_4 ] , var_6 [ var_5 - 1 ] + 1 )
      return var_6 [ - 1 ]
  