JAVA | Easy Solution Using Longest Common SubSequence
```\nclass Solution {\n    public int minInsertions(String s) {\n        StringBuilder S = new StringBuilder();\n        S.append(s);\n        return S.length()
```\nclass Solution {\n    public int minInsertions(String s) {\n        StringBuilder S = new StringBuilder();\n        S.append(s);\n        return S.length() - longestCommonSubsequence(s, S.reverse().toString());\n    }\n    public int longestCommonSubsequence(String text1, String text2) {\n        int m = text1.length(), n = text2.length();\n        int[][] dp = new int[m + 1][n + 1];\n        for(int i = 1; i <= m; i++)\n            for(int j = 1; j <= n; j++)\n                if(text1.charAt(i-1) == text2.charAt(j-1)) dp[i][j] = dp[i-1][j-1] + 1;\n                else dp[i][j] = Math.max(dp[i - 1][j], dp[i][j - 1]);\n        return dp[m][n];\n    }\n}
['Dynamic Programming', 'Java']