Simple Dp solution based on Longest common subsequence (LCS) Pattern
In lcs code we require 2 string inputs, here we have only 1 string input so we reverse it to get other string. After that we simply write our lcs code.\nFor bet
In lcs code we require 2 string inputs, here we have only 1 string input so we reverse it to get other string. After that we simply write our lcs code.\nFor better understanding of patterns in DP you can refer to **Aditya Verma\'s Playlist**:- \nhttps://www.youtube.com/playlist?list=PL_z_8CaSLPWekqhdCPmFohncHwz8TY2Go\n```\n    int minInsertions(string s) {\n        int n = s.size();\n        string b = s;\n        reverse(b.begin() , b.end());\n        \n        vector<vector<int>> dp(n+1 , vector<int>(n+1 , 0));\n        \n        for(int i = 1 ; i<=n ; i++){\n            for(int j = 1 ; j<= n ; j++){\n                if(s[i-1]==b[j-1])\n                    dp[i][j] = 1 + dp[i-1][j-1];\n                else\n                    dp[i][j] = max(dp[i-1][j] , dp[i][j-1]);\n            }\n        }\n        return n - dp[n][n];\n        \n    }\n```
[]