Striver Bhaiya 😎 Chad Approach🦸‍♂️ | Woh Bhi Space Optimized 🚀
\nclass Solution {\n    public int minInsertions(String s1) {\n\t    int n =s1.length();\n        String s2 ="";\n        for(int i=n-1; i>=0; i--) s2 += s1.cha
```\nclass Solution {\n    public int minInsertions(String s1) {\n\t    int n =s1.length();\n        String s2 ="";\n        for(int i=n-1; i>=0; i--) s2 += s1.charAt(i); // S2 = rev(S1) for L.P.S computation\n        \n        int dp[] = new int[n+1];\n        for(int i=1; i<=n; i++){ // Generating L.C.S ~ Space Optimized!\n            int cur[] = new int[n+1];\n            for(int j=1; j<=n; j++){\n                if(s1.charAt(i-1) == s2.charAt(j-1)) cur[j] = 1 + dp[j-1];\n                else cur[j] = Math.max(dp[j], cur[j-1]);\n            }\n            dp = cur;\n        } // Got our L.P.S\n        \n        // Now, min_operation = n - lps \n        return (n - dp[n]); // a c p c a \n    }\n}\n```
['Java']