Breaking Strings

Computer Science Level 4

You have an unwanted string of characters. Unfortunately, you can't just apply delete because your keyboard's d key isn't working. The only operation is break, which remove a subsegment consists of the same characters and concatenate both ends. What is the minimum number of break you need to apply to completely delete this string?

Explicit Example

  • The answer for string ababa is 3.
  • The answer for string abbccbba is 3.
  • The answer for string abcdefghi is 9.

Problem Loading...

Note Loading...

Set Loading...