```
public class Solution {
public int longestPalindrome(String s) {
if(s == null || s.length() == 0){
return 0;
}
int[] count = new int[256];
int sum = 0, odd = 0;
for(int i = 0; i < s.length(); i++){
sum++;
if(count[s.charAt(i)] % 2 == 1){
odd--;
}
else{
odd++;
}
count[s.charAt(i)]++;
}
return sum - Math.max(0, odd - 1);
}
}
```