


Input: 'str' = "abca"
Output: 1
Explanation:
If we insert the character ‘b’ after ‘c’, we get the string "abcba", which is a palindromic string. Please note that there are also other ways possible.
The first line contains a string 'str', containing lowercase English letters i.e from ‘a’ to ‘z’.
The output contains a single integer denoting the minimum number of insertions needed to make 'str' palindrome.
You do not need to print anything; it has already been taken care of. Just implement the given function.
Consider the string 'str' = “abcca” .
Suppose we want to find the ans for string “abcde”, then the recursive tree for string “abcde” is :
As we can see in the above diagram:
We can see that we were solving the same subproblems multiple times. Thus, this problem was exhibiting overlapping subproblems.
This means, in this approach, we need to eliminate the need for solving the same subproblems again and again. Thus, the idea is to use Memoization.
Initially, we were breaking the large problem into small problems but now, let us look at it differently. The idea is to solve the small problem first and then reach the final answer. Thus we will be using a bottom-up approach now.
For the test case where 'str' = “abcca”.