eayc C++ code o(n^2*2^n)
\n int maxProduct(string s) {\n        int n=s.length();\n        int ans=0;\n        for(int k=1;k<pow(2,n)-1;k++)\n        {\n            string unused="";\n 
```\n int maxProduct(string s) {\n        int n=s.length();\n        int ans=0;\n        for(int k=1;k<pow(2,n)-1;k++)\n        {\n            string unused="";\n            string used="";\n            for(int j=0;j<n;j++)\n            {\n                if(k&1<<j)\n                {\n                    used+=s[j];\n                }\n                else \n                {\n                    unused+=s[j];\n                }\n            }\n            \n            int check=1;\n            for(int j=0;j<used.length()/2;j++)\n            {\n                if(used[j]!=used[used.length()-j-1])\n                {\n                    check=0;\n                    break;\n                }\n            }\n            \n            if(!check)continue;\n            int m=unused.length();\n            vector<vector<int>>dp(m+1,vector<int>(m+1,0));\n            \n            for(int i=0;i<m;i++)dp[i][i]=1;\n            for(int i=0;i<m-1;i++)\n            {\n                if(unused[i]==unused[i+1])dp[i][i+1]=2;\n                else dp[i][i+1]=1;\n            }\n            for(int j=3;j<=m;j++)\n            {\n                for(int i=0;i<=m-j;i++)\n                {\n                    if(unused[i]==unused[i+j-1])dp[i][i+j-1]=dp[i+1][i+j-2]+2;\n                    else dp[i][i+j-1]=max(dp[i][i+j-2],dp[i+1][i+j-1]);\n                }\n            }\n            int u=used.length();            \n            ans=max(ans,u*dp[0][m-1]);\n        }\n        return ans;\n    }\n```
['Dynamic Programming', 'Bitmask']