c++|dp with bitamask +longest palindromic subsequence
\nclass Solution {\npublic:\n    bool check_palindrom(int m,string s){\n        int i=0;\n        string temp="";\n        while(m>0){\n            if(m&1){\n  
```\nclass Solution {\npublic:\n    bool check_palindrom(int m,string s){\n        int i=0;\n        string temp="";\n        while(m>0){\n            if(m&1){\n                temp+=s[i];\n            }\n            m=m>>1;\n            i++;\n        }\n        int start=0;\n        int end=temp.length()-1;\n        while(start<=end){\n            if(temp[start]!=temp[end])return false;\n            start++;\n            end--;\n        }\n        return true;\n    }\n    int find_ans(int m,string s){\n        int n=s.length();\n        string temp="";\n        for(int i=0;i<n;i++){\n            if((m&(1<<i))==0){\n                temp+=s[i];\n            }\n        }\n        int l=temp.length();\n        if(l==0)return 0;\n        vector<vector<int>>dp(l,vector<int>(l,0));\n        for(int i=0;i<l;i++)dp[i][i]=1;\n        for(int len=2;len<=l;len++){\n            for(int i=0;i+len-1<l;i++){\n                int j=i+len-1;\n                if(len==2){\n                    if(temp[i]==temp[j])dp[i][j]=2;\n                    else dp[i][j]=1;\n                }\n                else{\n                    if(temp[i]==temp[j])dp[i][j]=2+dp[i+1][j-1];\n                    else dp[i][j]=max(dp[i+1][j],dp[i][j-1]);\n                }\n            }\n        }\n        return dp[0][l-1];\n        \n    }\n    int maxProduct(string s) {\n        int n=s.length();\n        int ans=0;\n\t\t//firstly finding each subsequence of string s \n        for(int i=1;i<(1<<n);i++){\n            bool flag=check_palindrom(i,s); //checking the current subsequence is palindrome \n            if(!flag)continue;//if it is not palindrome continue to remaining subsequence\n            int len1=__builtin_popcount(i);\n            int len2=find_ans(i,s);//finding the maximum length subsequence which is palindrome in remaining string \n            ans=max(len1*len2,ans);\n            \n        }\n        return ans;\n    }\n};\n\n```
['Dynamic Programming', 'Bitmask']