Bit Masking
\nclass Solution {\npublic:\n    int maxProduct(string s) {\n        int n = s.length();\n        int p = pow(2,n);\n        vector<pair<int,int> > vec;\n      
```\nclass Solution {\npublic:\n    int maxProduct(string s) {\n        int n = s.length();\n        int p = pow(2,n);\n        vector<pair<int,int> > vec;\n        for(int i = 1;i < p;i++){\n            int a = isPalindrome(s,i);\n            if(a != -1)\n            vec.push_back({i,a});   \n        }\n        int ans = 1;\n        for(int i = 0;i < vec.size();i++)\n        for(int j = i+1;j < vec.size();j++)\n        if((vec[i].first & vec[j].first) == 0)\n        ans = max(ans,vec[i].second * vec[j].second); \n        return ans;\n        \n    }\n  int isPalindrome(string& s,int p){\n      vector<int> vec;\n      for(int i = 0;i < s.length();i++)\n      if(p & (1<<i))\n      vec.push_back(i);   \n      int index = vec.size()-1;\n      for(int i = 0;i <= index;i++,index--)\n      if(s[vec[i]] != s[vec[index]])\n      return -1;\n      return vec.size();\n   }\n};\n```
[]