First using set to reduce the circle times, then using
.count() to count the appear times. no matter the times is odd or even, the
// can calculate how many pairs properly.
2 * pairs + 1 can get the result, but if the String is full of characters that appear even times, the result should be the length of string itself. In this case we get min of them.
def longestPalindrome(self, s): """ :type s: str :rtype: int """ return min(len(s), 2 * sum(s.count(chr) // 2 for chr in set(s)) + 1)