title: Minimum Steps To Delete A String After Repeated Deletion Of Palindrome Substrings
signature: minimumStepsToDeleteAStringAfterRepeatedDeletionOfPalindromeSubstrings :: String -> Integer
  minimumStepsToDeleteAStringAfterRepeatedDeletionOfPalindromeSubstrings str = 
source_py: def minimum_steps_to_delete_a_string_after_repeated_deletion_of_palindrome_substrings(str):
      N = len(str)
      dp = [[0 for x in range((N + 1))] for y in range((N + 1))]
      for l in range(1, (N + 1)):
          i = 0
          j = (l - 1)
          while (j < N):
              if (l == 1):
                  dp[i][j] = 1
              else:
                  dp[i][j] = (1 + dp[(i + 1)][j])
                  if (str[i] == str[(i + 1)]):
                      dp[i][j] = min((1 + dp[(i + 2)][j]), dp[i][j])
                  for K in range((i + 2), (j + 1)):
                      if (str[i] == str[K]):
                          dp[i][j] = min((dp[(i + 1)][(K - 1)] + dp[(K + 1)][j]), dp[i][j])
              i += 1
              j += 1
      return dp[0][(N - 1)]
source_cpp: int minimum_steps_to_delete_a_string_after_repeated_deletion_of_palindrome_substrings(string str) {
    int N = str . length ( );
    int dp [ N + 1 ] [ N + 1 ];
    for ( int i = 0;
    i <= N;
    i ++ ) for ( int j = 0;
    j <= N;
    j ++ ) dp [ i ] [ j ] = 0;
    for ( int len = 1;
    len <= N;
    len ++ ) {
      for ( int i = 0, j = len - 1;
      j < N;
      i ++, j ++ ) {
        if ( len == 1 ) dp [ i ] [ j ] = 1;
        else {
          dp [ i ] [ j ] = 1 + dp [ i + 1 ] [ j ];
          if ( str [ i ] == str [ i + 1 ] ) dp [ i ] [ j ] = min ( 1 + dp [ i + 2 ] [ j ], dp [ i ] [ j ] );
          for ( int K = i + 2;
          K <= j;
          K ++ ) if ( str [ i ] == str [ K ] ) dp [ i ] [ j ] = min ( dp [ i + 1 ] [ K - 1 ] + dp [ K + 1 ] [ j ], dp [ i ] [ j ] );
        }
      }
    }
    return dp [ 0 ] [ N - 1 ];
  }