pyassistant

Minimum moves to delete a string by removing palindromic substrings

You are given a string s. In one move you may choose any contiguous substring of s that is a palindrome (length >= 1) and remove it. After removal the remaining parts concatenate. Compute the minimum number of moves required to delete the whole string. Return the minimum number of moves.

Example:

Input:
('abacaba',)
Output:
1

Make sure you return your solution, don't print!

AI

Bot

Trying to solve my challenge? Ask if you must, or press the purple button so I can analyze your code.