recursion and bitset
This approach:\n identify all palindroms\n store found palindroms as  a bitset of their character positions in an unordered set\n* enumerate all combinations to
This approach:\n* identify all palindroms\n* store found palindroms as  a bitset of their character positions in an unordered set\n* enumerate all combinations to find the max product (length is how many bits are set)\n\n\nExplaining a bit the   recursion:  we can either have  a character or not in the sequence we are building\n\n\n```\n\n    string input;\n    bool is_pal(const string& str) const {\n        if (str.empty())\n            return false;\n        if (str.size() == 1)\n            return true;\n        for (size_t pos = 0; pos != str.size() / 2; ++pos) {            \n            if (str[pos] != str[str.size() - pos - 1])\n                return false;            \n        }\n        return true;\n    }\n    \n      unordered_set<bitset<12>> all_pals;\n     \n    void find_all_pals(const string& str, bitset<12> poses, const size_t pos)  {\n       \n        if (is_pal(str)) {\n            \n            all_pals.insert(poses);\n        }\n        \n        if (pos == input.size() )\n            return ;\n        \n        find_all_pals(str, poses, pos + 1);        \n        poses.set(pos);\n        find_all_pals(str + input[pos], poses, pos + 1);\n        \n        \n    }\npublic:\n    int maxProduct(string s) {\n    \n        input = s;\n        \n        find_all_pals("", {}, 0);\n        \n        \n        int count {0};\n        for (const auto& first : all_pals) {\n            for (const auto& second : all_pals) { \n                if ((first & second).none()) {\n                    count = max<int>(count, first.count() * second.count());\n                }\n            }\n        }\n        \n        \n        \n        return count;\n    }
['C']