Java - Bit Mask
\nclass Solution {\n    public int maxProduct(String s) {\n        HashMap<Integer,Integer> map=new HashMap<>(); // KEY=bit mask , VALUE= length of the string g
```\nclass Solution {\n    public int maxProduct(String s) {\n        HashMap<Integer,Integer> map=new HashMap<>(); // KEY=bit mask , VALUE= length of the string generated from that mask\n        int n=s.length();\n        for(int mask=0;mask<(1<<n);mask++){// generate bitmask from 1 to 2^n \n            String temp="";\n            for(int i=0;i<n;i++){ \n                if((mask & (1<<i)) !=0) // generate the string from the mask \n                    temp+=s.charAt(i);\n            }\n            \n            if(isPali(temp)){ // check if its a palindrome\n                map.put(mask,temp.length()); \n            }\n        }\n        \n        int res=0;\n        for(int i: map.keySet()){\n            for(int j :map.keySet()){\n                if((i&j)==0){ // if AND of two bitmask is zero means they are disjoint\n                    res=Math.max(res, map.get(i)*map.get(j));\n                }\n            }\n        }\n        \n        return res;\n        \n        \n        \n        \n    }\n    \n    private boolean isPali(String s){\n        int i=0;\n        int j=s.length()-1;\n        while(i<j){\n            if(s.charAt(i)!=s.charAt(j))\n                return false;\n            i++;\n            j--;\n        }\n        return true;\n    }\n}\n```
['Bitmask']