C++ || Check All subsequences
Check All subsequences\nand check their lps.\nthen finally return the max possible ans.\n\nclass Solution {\npublic:\n    int ans=1;\n    unordered_map<string,i
Check All subsequences\nand check their lps.\nthen finally return the max possible ans.\n```\nclass Solution {\npublic:\n    int ans=1;\n    unordered_map<string,int>um;\n    void func(string s,string x,string y,int i){\n        \n        if(i==s.length()){\n            ans=max(ans,functiontofindlps(x)*functiontofindlps(y));\n            return ;\n        }\n        func(s,x+s[i],y,i+1);\n        func(s,x,y+s[i],i+1);\n    }\n    int functiontofindlps(string s){\n        int n=s.length();\n        if(n==0)return 0;\n        if(um.count(s))return um[s];\n        vector<vector<int>>dp(n+1,vector<int>(n+1));\n        string r=s;\n        reverse(s.begin(),s.end());\n        for(int i=1;i<=n;i++){\n            for(int j=1;j<=n;j++){\n                if(s[i-1]==r[j-1]){\n                    dp[i][j]=dp[i-1][j-1]+1;\n                }else{\n                    dp[i][j]=max(dp[i-1][j],dp[i][j-1]);\n                }\n            }\n        }\n        return um[s]=dp[n][n];\n    }\n    int maxProduct(string s) {\n        func(s,"","",0);\n        return ans;\n    }\n};\n```
['Backtracking', 'C']