problem
solution1:
class Solution { public: int longestPalindrome(string s) { map<char, int> temp; for(auto it:s) temp[it]++; int even = 0, odd = 0, mid=false; for(auto it=temp.begin(); it!=temp.end(); ++it) { if(it->second % 2==0) even+=it->second; else { mid = true; odd += it->second-1; } } return even+(mid?(odd+1):0); } };
参考
1. Leetcode_409. Longest Palindrome;
完