Author: Anurag Anand
Tester: Vaibhav Gosain
Given a string, find the minimum number of substrings to remove such that after all the removals, the string is a palindrome.
The answer is always 0 or 1.
There are two cases:
- The string is already a palindrome - In this case the answer is 0
- The string is not a palindrome - In this we can remove all the characters except the first character. So, the remaining string has a single character and hence is a palindrome. Hence, in this case, the answer is 1.
Author’s solution can be found here.