Simple Java DP Solution - Top Down Recursion
\nclass Solution {\n    public int maxProduct(String s) {\n        return maxProduct(s, 0, "","");\n    }\n    Map<String, Integer> dp = new HashMap<>();\n    p
```\nclass Solution {\n    public int maxProduct(String s) {\n        return maxProduct(s, 0, "","");\n    }\n    Map<String, Integer> dp = new HashMap<>();\n    public int maxProduct(String s, int ci, String s1, String s2) {\n        int max = 0;\n        String key = ci+"_"+s1 +"_"+s2;\n        \n        if(dp.containsKey(key))\n            return dp.get(key);\n        if(ci==s.length()){\n            if(s1.length()>0 && s2.length()>0 && isPalindrome(s1) && isPalindrome(s2)){\n                return s1.length()*s2.length();\n            }\n            return max;\n        }\n        max = Math.max(Math.max(maxProduct(s, ci+1, s1+s.charAt(ci), s2),\n        maxProduct(s, ci+1, s1, s2+s.charAt(ci))), maxProduct(s, ci+1, s1, s2));\n        dp.put(key, max);\n        return max;\n    }\n    boolean isPalindrome(String s){\n        int start = 0, end = s.length()-1;\n        while(start<end){\n            if(s.charAt(start)!=s.charAt(end))\n                return false;\n            start++;\n            end--;\n        }\n        return true;\n    }\n}\n```
[]