I have no idea on how to deal with the insertions problem in a similar way to minimum deletions problem. Can anyone share their codes?
Here’s the code which will return a minimum number of insertions to make in a string to make it a palindrome:
int findMinimumInsertion(string str)
{
int n = str.length();
int total = 0;
int count[50] = {};
for (int i = 0; i < n; i++)
count[str[i] - 'a']++;
for (int i = 0; i < 50; i++)
if (count[i] % 2 == 1)
total++;
if(total==0)
return 0;
else
return total-1;
}