c++ solution (lcs)
https://leetcode.com/problems/longest-palindromic-subsequence/\n\nclass Solution {\npublic:\n    int lps(string &s)\n    {\n        int n=s.size();\n        str
[https://leetcode.com/problems/longest-palindromic-subsequence/](http://)\n```\nclass Solution {\npublic:\n    int lps(string &s)\n    {\n        int n=s.size();\n        string s1=s;\n        string s2=s;\n        reverse(s2.begin(),s2.end());\n        int dp[s.size()+1][s.size()+1];\n        memset(dp,0,sizeof(dp));\n        for(int i=1;i<=n;i++)\n        {\n            for(int j=1;j<=n;j++)\n            {\n                dp[i][j]=(s1[i-1]==s2[j-1])?1+dp[i-1][j-1]:max(dp[i][j-1],dp[i-1][j]);\n            }\n        }\n        return dp[n][n];\n    }\n    int maxProduct(string s) \n    {\n        int ans=0;\n        int n=s.size();\n        for(int i=1;i<(1<<n)-1;i++)\n        {\n            string s1="",s2="";\n            for(int j=0;j<n;j++)\n            {\n                if(i&(1<<j))\n                {\n                    s1.push_back(s[j]);\n                }\n                else\n                {\n                    s2.push_back(s[j]);\n                }\n            }\n            ans=max(ans,lps(s1)*lps(s2));\n        }\n        return ans;\n    }\n    \n};\n```
['C', 'Bitmask', 'C++']