1ms Java Solution with Test Case
\nclass Solution {\n    // ""\n    // "AaAa"\n    // "aaa"\n    // "aaaa"\n    // "AAA"\n    // "AAAA"\n    // "AacAaa"\n    // Time: O(n)\n    // Space: O(1)\n
```\nclass Solution {\n    // ""\n    // "AaAa"\n    // "aaa"\n    // "aaaa"\n    // "AAA"\n    // "AAAA"\n    // "AacAaa"\n    // Time: O(n)\n    // Space: O(1)\n    public int longestPalindrome(String s) {\n        if (s == null) return 0;\n        \n        int[] count = new int[128];\n        for (char c : s.toCharArray()) {\n            count[c]++;\n        }\n        \n        int res = 0;\n        for (int num : count) {\n            res += (num/2) * 2;\n        }\n        \n        return res == s.length() ? res : res + 1;\n    }\n}\n```
[]