C++ || Hashmap || Simple + Optimal || 0 ms || Beats 100%
\n# Code\n\nclass Solution {\npublic:\n    int longestPalindrome(string s) {\n        unordered_map<char, int> mp;\n        for(auto i : s) {\n            mp[i]
\n# Code\n```\nclass Solution {\npublic:\n    int longestPalindrome(string s) {\n        unordered_map<char, int> mp;\n        for(auto i : s) {\n            mp[i]++;\n        }\n        int ans = 0;\n        bool isOddPresent = false;\n        for(auto i : mp) {\n            if(i.second % 2 == 0) ans += i.second;\n            else {\n                ans += i.second - 1;\n                isOddPresent = true;\n            }\n        }\n        if(isOddPresent) ans += 1;\n        return ans;\n    }\n};\n```
['Hash Table', 'String', 'Greedy', 'C++']