title: Dynamic Programming Set 28 Minimum Insertions To Form A Palindrome
signature: func dynamicProgrammingSet28MinimumInsertionsToFormAPalindrome(str []rune, l int, h int) int {
source_py: def dynamic_programming_set_28_minimum_insertions_to_form_a_palindrome(str, l, h):
      if (l > h):
          return sys.maxsize
      if (l == h):
          return 0
      if (l == (h - 1)):
          return (0 if (str[l] == str[h]) else 1)
      if (str[l] == str[h]):
          return dynamic_programming_set_28_minimum_insertions_to_form_a_palindrome(str, (l + 1), (h - 1))
      else:
          return (min(dynamic_programming_set_28_minimum_insertions_to_form_a_palindrome(str, l, (h - 1)), dynamic_programming_set_28_minimum_insertions_to_form_a_palindrome(str, (l + 1), h)) + 1)
source_cpp: int dynamic_programming_set_28_minimum_insertions_to_form_a_palindrome(vector<char> str, int l, int h) {
    if ( l > h ) return INT_MAX;
    if ( l == h ) return 0;
    if ( l == h - 1 ) return ( str [ l ] == str [ h ] ) ? 0 : 1;
    return ( str [ l ] == str [ h ] ) ? dynamic_programming_set_28_minimum_insertions_to_form_a_palindrome ( str, l + 1, h - 1 ) : ( min ( dynamic_programming_set_28_minimum_insertions_to_form_a_palindrome ( str, l, h - 1 ), dynamic_programming_set_28_minimum_insertions_to_form_a_palindrome ( str, l + 1, h ) ) + 1 );
  }