simple python DP solution: longest common subsequence variation.
Let the first string be a. then take a new string b which is reversed of a.\napply longest common subsequnce on both the strings and subtract the answer from th
Let the first string be a. then take a new string b which is reversed of a.\napply longest common subsequnce on both the strings and subtract the answer from the length of the string.\nit works for minimum number of deletion as well as minimum number of insertion to make a string palindrome.\n\n\tclass Solution:\n\t\tdef minInsertions(self, a: str) -> int:\n\t\t\tb = a[::-1]\n\t\t\tn = len(a)\n\n\t\t\tdp = [[0 for x in range(n + 1)] for y in range(n + 1)]\n\n\t\t\tfor i in range(1, n + 1):\n\t\t\t\tfor j in range(1, n + 1):\n\t\t\t\t\tif a[i - 1] == b[j - 1]:\n\t\t\t\t\t\tdp[i][j] = 1 + dp[i - 1][j - 1]\n\n\t\t\t\t\telse:\n\t\t\t\t\t\tdp[i][j] = max(dp[i - 1][j], dp[i][j - 1])\n\n\t\t\treturn n - dp[-1][-1]
['Dynamic Programming', 'Python', 'Python3']