title: Minimum Steps To Delete A String After Repeated Deletion Of Palindrome Substrings
signature: def minimum_steps_to_delete_a_string_after_repeated_deletion_of_palindrome_substrings(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 ];
  }
question_info.test_code: import array
  import bisect
  import collections
  import datetime
  import functools
  import heapq
  import itertools
  import math
  import queue
  import re
  import string
  import sys
  from typing import Any, Dict, List, Optional, Set
  
  
  # SOLUTION CODE
  # ============================================
  PLACEHOLDER_CODE_BODY
  
  # TESTING CODE 
  # ============================================
  def validate_solution(actual, expected):
      return actual == expected
  
  def driver(str, expected):
      try:
          if validate_solution(PLACEHOLDER_FN_NAME(
              str),
              expected
          ):
              return "PASSED"
          return "FAILED"
      except Exception as exception_obj:
          return type(exception_obj).__name__
      
  if __name__ == "__main__":
      result = driver("YCtLQtHLwr", 8)
      print(f"TEST-0...{result}")
  
      result = driver("47713514383248", 7)
      print(f"TEST-1...{result}")
  
      result = driver("0100101001111", 3)
      print(f"TEST-2...{result}")
  
      result = driver("XfdIYVn", 7)
      print(f"TEST-3...{result}")
  
      result = driver("45499225407", 5)
      print(f"TEST-4...{result}")
  
      result = driver("000100111001", 2)
      print(f"TEST-5...{result}")
  
      result = driver("ZoUQhQwoap", 6)
      print(f"TEST-6...{result}")
  
      result = driver("18579027952", 7)
      print(f"TEST-7...{result}")
  
      result = driver("00000001111", 2)
      print(f"TEST-8...{result}")
  
      result = driver("JD", 2)
      print(f"TEST-9...{result}")
  
      sys.exit(0)
question_info.test_case_ids: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
question_info.entry_fn_name: minimum_steps_to_delete_a_string_after_repeated_deletion_of_palindrome_substrings
question_info.test_list: [{"idx": 0, "outputs": 8, "inputs": {"str": "YCtLQtHLwr"}}, {"idx": 1, "outputs": 7, "inputs": {"str": "47713514383248"}}, {"idx": 2, "outputs": 3, "inputs": {"str": "0100101001111"}}, {"idx": 3, "outputs": 7, "inputs": {"str": "XfdIYVn"}}, {"idx": 4, "outputs": 5, "inputs": {"str": "45499225407"}}, {"idx": 5, "outputs": 2, "inputs": {"str": "000100111001"}}, {"idx": 6, "outputs": 6, "inputs": {"str": "ZoUQhQwoap"}}, {"idx": 7, "outputs": 7, "inputs": {"str": "18579027952"}}, {"idx": 8, "outputs": 2, "inputs": {"str": "00000001111"}}, {"idx": 9, "outputs": 2, "inputs": {"str": "JD"}}]
question_info.entry_cls_name: Solution