Java brute force using DP. IF anyone knows a better solution please share
\nclass Solution {\n    public int minInsertions(String s) {\n        int len = s.length();\n        StringBuilder sb = new StringBuilder();\n        sb.append(
```\nclass Solution {\n    public int minInsertions(String s) {\n        int len = s.length();\n        StringBuilder sb = new StringBuilder();\n        sb.append(s);\n        sb.reverse();\n        int [][] dp = new int[len+1][len+1];\n        \n        for(int i =0;i<len+1;i++){\n            dp[i][0]=0;\n        }\n        for(int j =0;j<len+1;j++){\n            dp[0][j]=0;\n        }\n        for(int i =1;i<len+1;i++){\n            for(int j=1;j<len+1;j++){\n                if(s.charAt(i-1)==sb.charAt(j-1))\n                    dp[i][j]=1+dp[i-1][j-1];\n                else\n                    dp[i][j] =Math.max(dp[i-1][j], dp[i][j-1]);\n            }\n        }\n        return len-dp[len][len];\n    }\n}\n```
['Dynamic Programming', 'Java']