Solution 1 使用map
int longestPalindrome(string s)
{
int cnt = 0;
map<char, int> m;
for(int i = 0; i < s.length(); i++)
{
if(m.find(s[i]) == m.end())
{
m[s[i]] = 1;
continue;
}
if(m[s[i]] % 2 == 1)
cnt += 2;
m[s[i]] ++;
}
if(cnt < s.length())
cnt ++;
return cnt;
}