Medium Accuracy: 53.0%
Submissions: 12171 Points: 4
Given a string, find the minimum number of characters to be inserted to convert it to palindrome.
ab: Number of insertions required is 1. bab or aba
aa: Number of insertions required is 0. aa
abcd: Number of insertions required is 3. dcbabcd
Input: str = "abcd"
Explanation: Inserted character marked
with bold characters in dcbabcd
Input: str = "aa"
Explanation:"aa" is already a palindrome.
You don't need to read input or print anything. Your task is to complete the function countMin() which takes the string str as inputs and returns the answer.
Expected Time Complexity: O(N2), N = |str| Expected Auxiliary Space: O(N2)
1 ≤ |str| ≤ 103
str contains only lower case alphabets.