Longest Palindromic Subsequence | Aditya Verma's approach
Just find the length of Longest Palindromic Subsequence and subtract it from the string size (in the same way we can calculate "minimum number of deletions to m
Just find the length of Longest Palindromic Subsequence and subtract it from the string size (in the same way we can calculate "minimum number of deletions to make a string palindrome").\n```\nclass Solution {\npublic:\n    int lcs(int x, int y, string s1, string s2)\n    {\n        int dp[x+1][y+1];\n        \n        for(int i = 0; i <= x; i++)\n        {\n            dp[i][0] = 0;\n        }\n        \n        for(int j = 0; j <= y; j++)\n        {\n            dp[0][j] = 0;\n        }\n        \n        for(int i = 1; i <= x; i++)\n        {\n            for(int j = 1; j <= y; j++)\n            {\n                if(s1[i-1] == s2[j-1])\n                {\n                    dp[i][j] = 1 + dp[i-1][j-1];\n                }\n                else\n                {\n                    dp[i][j] = max(dp[i-1][j], dp[i][j-1]);\n                }\n            }\n        }\n        \n        return dp[x][y];\n    }\n    int minInsertions(string A) {\n        int n = A.size();\n        string B = A;\n        reverse(B.begin(),B.end());\n        return n - lcs(n,n,A,B);\n    }\n};\n```
['Dynamic Programming', 'C']