Bit Masking|| Dynamic Programming|| Faster then 94% of C++ users
Complexity\n- Time complexity:O(2^(2N))\n Add your time complexity here, e.g. O(n) \n\n# Code\n\nclass Solution {\npublic:\n    bool palindrome(string &s) {\n  
# Complexity\n- Time complexity:O(2^(2N))\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    bool palindrome(string &s) {\n        int i = 0;\n        int j = s.length() - 1;\n        while (i < j) {\n            if (s[i] != s[j])\n                return false;\n            i++;\n            j--;\n        }\n        return true;\n    }\n\n    int maxProduct(string s) {\n        int n = s.length();\n        int mask = 1 << n;\n        vector<pair<string, int>> pSubs;\n        \n        // Generate all subsequences and check if they are palindromes\n        for (int i = 0; i < mask; i++) {\n            string s2 = "";\n            for (int j = 0; j < n; j++) {\n                if ((1 << j) & i) {\n                    s2.push_back(s[j]);\n                }\n            }\n            if (palindrome(s2)) {\n                pSubs.push_back({s2, i});\n            }\n        }\n        \n        int x = pSubs.size();\n        int maxProduct = 0;\n        \n        \n        for (int i = 0; i < x; i++) {\n            for (int j = i + 1; j < x; j++) {\n                int mask1 = pSubs[i].second;\n                int mask2 = pSubs[j].second;\n                \n                if ((mask1 & mask2) == 0) {\n                    int product = pSubs[i].first.size() * pSubs[j].first.size();\n                    maxProduct = max(maxProduct, product);\n                }\n            }\n        }\n        \n        return maxProduct;\n    }\n};\n\n```
['Dynamic Programming', 'Bit Manipulation', 'Bitmask', 'C++']