c++|bitmasking
class Solution {\npublic:\n    int maxProduct(string s) {\n        map m; //\n            int n=s.length();\n        \n            for(int mask=1;mask<(1<<n);ma
class Solution {\npublic:\n    int maxProduct(string s) {\n        map<int ,int> m; //<bitmask,length>\n            int n=s.length();\n        \n            for(int mask=1;mask<(1<<n);mask++)\n            {\n                string subseq="";\n                for(int i=0;i<n;i++)\n                {\n                    if(mask &  (1<<i))\n                    {\n                        subseq+=s[i];\n                    }\n                }\n                string chk=subseq;\n                reverse(chk.begin(),chk.end());\n                if((subseq)==chk)\n                {\n                    m[mask]=subseq.length();\n                }\n                \n            }\n        int ans=0;\n        for(auto m1:m)\n        {\n            for(auto m2:m)\n            {\n                if(((m1.first)&(m2.first))==0)\n                    ans=max(ans,(m1.second)*(m2.second));\n                \n            }\n        }\n        return ans;\n    }\n};
['Bitmask']