Longest Palindrome

给一个字符串, 找出其中最长的回文, 返回它的长度.

public class Solution {
    public int longestPalindrome(String s) {
        if(s == null || s.length() == 0)
            return 0;
        Set<Character> set = new HashSet<Character>();
        int count = 0;
        for(int i = 0 ; i < s.length(); i++) {
            if(set.contains(s.charAt(i))){
                set.remove(s.charAt(i));
                count++;
            }
            else{
                set.add(s.charAt(i));
            }
        }
        if(!set.isEmpty())
            return count*2+1;
        else
            return count*2;
    }
}