[C++] Backtracking Solution
\nclass Solution {\n    int ans;\n    // Check for palindrome\n    bool isPalindrome(string& temp){\n        int i=0,j = temp.length() - 1;\n        while(i<j){
```\nclass Solution {\n    int ans;\n    // Check for palindrome\n    bool isPalindrome(string& temp){\n        int i=0,j = temp.length() - 1;\n        while(i<j){\n            if(temp[i]!=temp[j]){\n                return false;\n            }\n            i++,j--;\n        }\n        return true;\n    }\n    \n    void helper(int i,string& str,string temp,int prev,vector<bool> &vis){\n        if(i==str.length()){\n            if(isPalindrome(temp)){\n\t\t\t\t// If we have already found 1 palindromic subsequence\n                if(prev!=-1){\n                    int s = temp.length();\n                    ans=max(ans,prev*s);\n                }\n                else{ // Search for another palindromic subsequence\n                    helper(0,str,"",temp.length(),vis);\n                }\n            }\n            return ; \n        }\n        helper(i+1,str,temp,prev,vis);\n        if(!vis[i]){\n            vis[i]=true;\n            helper(i+1,str,temp+str[i],prev,vis);\n            vis[i]=false;\n        }\n    }\n    \npublic:\n    int maxProduct(string s) {\n        ans = 0;\n        vector<bool> vis(s.length(),false);\n        helper(0,s,"",-1,vis);\n        return ans;\n    }\n};\n```
['Backtracking', 'C']