C++ solution using hashmap ✅
Logic\nAll elements on either side of the palindrome have to be even if number so that thay can equally be distributed on each side. Other than the only element
# Logic\nAll elements on either side of the palindrome have to be even if number so that thay can equally be distributed on each side. Other than the only element which can have odd number of times repeated is the one at the middle in case of a string of odd length.\n\n*Example: ababcccbaba*\n\nOther than c all other elements are even in numbers/quantity. Only c is odd as it is centered [though even number of c\'s is also allowed]\n\n\n``` C++ []\nclass Solution {\npublic:\n    int longestPalindrome(string s) {\n        unordered_map<char, int> mp;\n        for (char x:s) {\n            mp[x]++;\n        }\n        int length=0, carry=0;\n        for (auto x:mp) {\n            if (x.second%2==1) {\n                carry=1;\n                length+=(x.second-1);\n            } else length+=x.second;\n        }\n        return length+carry;\n    }\n};\n```\n# My GitHub: https://github.com/crimsonKn1ght\n\n*If this code helps, please upvote it, it encourages me to write more solutions*\n
['Hash Table', 'C++']