Java | Backtracking
\n\nclass Solution {\n    private int maxProduct;\n\n    public int maxProduct(String s) {\n        maxProduct = 0;\n        populateMaxProduct(s, new StringBui
```\n\nclass Solution {\n    private int maxProduct;\n\n    public int maxProduct(String s) {\n        maxProduct = 0;\n        populateMaxProduct(s, new StringBuilder(), new StringBuilder(), 0);\n        return maxProduct;\n    }\n\n    private void populateMaxProduct(String s, StringBuilder s1, StringBuilder s2, int pos) {\n        int length = s.length();\n        if(pos == length) {\n            if(isPalindrome(s1.toString()) && isPalindrome(s2.toString())) {\n                maxProduct = Math.max(maxProduct, (s1.length() * s2.length()));\n            }\n            return;\n        }\n        char ch = s.charAt(pos);\n        s1.append(ch);\n        populateMaxProduct(s, s1, s2, (pos + 1));\n        s1.deleteCharAt(s1.length() - 1);\n        s2.append(ch);\n        populateMaxProduct(s, s1, s2, (pos + 1));\n        s2.deleteCharAt(s2.length() - 1);\n        populateMaxProduct(s, s1, s2, (pos + 1));\n    }\n\n    private boolean isPalindrome(String s) {\n        int low = 0, high = (s.length() - 1);\n        while(low < high) {\n            if(s.charAt(low) != s.charAt(high)) {\n                return false;\n            }\n            low++;\n            high--;\n        }\n        return true;\n    }\n}\n\n```
[]