class Solution {
public int longestPalindrome(String s) {
int[] count = new int[256];
for (char c : s.toCharArray()) {
count[c]++;
}
int total = 0;
int odd = 0;
for (int c : count) {
if (c % 2 == 0) {
total += c;
} else {
total += c - 1;
odd = 1;
}
}
return total + odd;
}
}
def longestPalindrome(self, s):
odds = sum(v & 1 for v in collections.Counter(s).values())
return len(s) - odds + bool(odds)