This is an interview question: \"You\'re given a string, and you want to split it into as few strings as possible such that each string is a palindrome\". (I guess a one char st
bool ispalindrome(string inp)
{
if(inp == "" || inp.length() == 1)
{
return true;
}
string rev = inp;
reverse(rev.begin(), rev.end());
return (rev == inp);
}
int minsplit_count(string inp)
{
if(ispalindrome(inp))
{
return 0;
}
int count= inp.length();
for(int i = 1; i < inp.length(); i++)
{
count = min(count,
minsplit_count(inp.substr(0, i)) +
minsplit_count(inp.substr(i, inp.size() - i)) +
1);
}
return count;
}