package leetcode;

/**
 * https://leetcode.com/problems/longest-palindrome/
 */
public class Problem409 {
    public int longestPalindrome(String s) {
        // TODO
        return 0;
    }

    public static void main(String[] args) {
        Problem409 prob = new Problem409();
        System.out.println(prob.longestPalindrome("abccccdd")); // 7
    }
}

@@ -12,16 +12,65 @@
 tcode;%0A%0A
+import java.util.HashMap;%0Aimport java.util.Map;%0A%0A
 /**%0A * h
@@ -205,82 +205,183 @@
     
-// TODO%0A        return 0;
+Map%3CCharacter, Integer%3E charCount = new HashMap%3C%3E();%0A        for (int i = 0; i %3C s.length(); i++) %7B
 %0A    
-%7D%0A%0A
+ 
     
-public static void main(String%5B%5D args
+   char c = s.charAt(i);%0A            if (!charCount.containsKey(c)
 ) %7B%0A
@@ -392,112 +392,495 @@
     
+   
-Problem409 prob = new Problem409();%0A        System.
+     charCount.put(c, 1);%0A            %7D else %7B%0A                charCount.put(c, charCount.get(c) + 1);%0A            %7D%0A        %7D%0A        int result = 0;%0A        boolean hasOdd = false;%0A        for (Map.Entry%3CCharacter, Integer%3E entry : charC
 ou
+n
 t.
-println(prob.longestPalindrome(%22abccccdd%22)); // 7
+entrySet()) %7B%0A            if (entry.getValue() %25 2 != 0) %7B%0A                hasOdd = true;%0A            %7D%0A            result += (entry.getValue() / 2) * 2;%0A        %7D%0A        if (hasOdd) %7B%0A            result++;%0A        %7D%0A        return result;
 %0A   

Solve problem 409