MOST OPTIMIZED C++ SOLUTION
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->image.png\n![image.png](https://assets.leetcode.com/users/images/d110de35-1acd-479d-97e3-2e47eb4a7210_1713313889.1943839.png)\n\n# Code\n```\nclass Solution {\npublic:\n    int maxProduct(string s) {\n        ios_base::sync_with_stdio(false);\n        cin.tie(nullptr);\n        cout.tie(nullptr);\n        int n = s.size();\n        int target = 1 << n;\n        unordered_map<int, int> mp;\n        string temp;\n        for(int mask = 0; mask < target; mask++)\n        {\n            temp = "";\n            for(int i = 0; i < n; i++)\n            {\n                if(mask & (1 << i))\n                {\n                    temp += s[i];\n                }\n            }\n            if(temp == string(temp.rbegin(), temp.rend()))\n            {   \n                mp[mask] = temp.size();\n            }   \n        }\n        int res = 0;\n        for(auto first = mp.begin(); first != mp.end(); first++)\n        {\n            for(auto second = next(first); second != mp.end(); second++)\n            {\n                if((first->first & second->first) == 0)\n                {\n                    res = max(res, first->second * second->second);\n                }\n            }\n        }\n        return res;\n    }\n};\n\n```
['C++']