JAVA || Memoization || Optimal Solution || Easy Soltion
\n\nclass Solution {\n    \n    int ans =  1;\n    \n    public int maxProduct(String s) {\n        \n        int[][] dp = new int[s.length() + 1][s.length() + 
\n```\nclass Solution {\n    \n    int ans =  1;\n    \n    public int maxProduct(String s) {\n        \n        int[][] dp = new int[s.length() + 1][s.length() + 1];\n        \n        for(int[] d: dp)\n            Arrays.fill(d, -1);\n        \n        int res = solve(s, "", "", 0, dp);\n        \n        return res;\n        \n    }\n    public int solve(String s, String s1, String s2, int i, int[][] dp)\n    {\n        int s1l = s1.length();\n        int s2l = s2.length();\n        \n        \n\n        if(isPali(s1) && isPali(s2))\n        {\n            ans = Math.max(ans, s1.length()*s2.length());\n        }\n        \n        dp[s1l][s2l] = ans;\n        \n        \n        if(i >= s.length())\n        {\n            return dp[s1l][s2l];\n        }\n           \n        int op1 = solve(s, s1 + s.charAt(i), s2, i + 1, dp);\n        int op2 = solve(s, s1, s2 + s.charAt(i), i + 1, dp);\n        int op3 = solve(s, s1, s2, i + 1, dp);\n        \n        return dp[s1l][s2l];\n    }\n    public boolean isPali(String s)\n    {\n        int i = 0;\n        int j = s.length() - 1;\n        while(i < j)\n        {\n            if(s.charAt(i) != s.charAt(j))\n                return false;\n            i++;\n            j--;\n        }\n        return true;\n    }\n}\n```
['Java']