力扣第409题 最长回文串
class Solution {
public:
int longestPalindrome(string s) {
map<char, int> m_Map;
for (int i = 0; i < s.size(); i++)
{
++m_Map[s[i]];
}
bool state = false;
int res = 0;
for (map<char, int>::iterator itor = m_Map.begin(); itor != m_Map.end(); itor++)
{
if ((*itor).second & 1)
{
state = true;
res += (*itor).second - 1;
}
else
{
res += (*itor).second;
}
}
if (state)
res++;
return res;
}
};