Easy Detailed Sol || C++ Backtracking
Intuition\nas the constraints are too small we can look for generating all possible subsequences and then check whether they are distinct or not and calculate t
# Intuition\nas the constraints are too small we can look for generating all possible subsequences and then check whether they are distinct or not and calculate the answer \n\n# Approach\nso what i did was to first i made all subsequences using bitmask and then i pushed the bitmask of the string which is a palindrome in a vector v after that i iterated over v vector and checked every pair which are distinct and updated the ans\n\n# Complexity\n- Time complexity:\nThe time complexity of the given code is O(2^N * N^2), where N is the length of the input string \'s\'.\n\n- Space complexity:\nThe space complexity of the given code is O(2^N * N), where N is the length of the input string \'s\'.\n\n# Code\n```\nclass Solution {\npublic:\n    bool check(string &s){\n        if(s.size()==0){\n            return false;\n        }\n        int i=0;\n        int n=s.size();\n        int j=n-1;\n        while(i<j){\n            if(s[i]!=s[j]){\n                return false;\n            }\n            i++;\n            j--;\n        }\n        return true;\n    }\n    int maxProduct(string s) {\n        int n=s.size();\n        int tot=(1<<n)-1;\n        vector<int> v;\n        for(int bitmask=0; bitmask<=tot; bitmask++){\n            string temp="";\n           for(int j=0;j<n; j++){\n               if(bitmask & (1<<j)){\n                   temp+=s[j];\n               }\n           }\n           if(check(temp)){\n               v.push_back(bitmask);\n           }\n        }\n        int ans=0;\n        for(int i=0; i<v.size(); i++){\n            for(int j=i+1; j<v.size(); j++){\n                if((v[i] & v[j])==0){\n                    int a=__builtin_popcount(v[i]);\n                    int b=__builtin_popcount(v[j]);\n                    ans=max(ans,a*b);\n                }\n            }\n        }\n        return ans;\n    }\n};\n```
['Backtracking', 'Bit Manipulation', 'Bitmask', 'C++']