[Java] Simple O(n) time solution with O(alphabetSize) space
\nclass Solution {\n    public int longestPalindrome(String s) {\n        int[] counts = new int[52];\n        \n        for (int i = 0; i < s.length(); i++) {\
```\nclass Solution {\n    public int longestPalindrome(String s) {\n        int[] counts = new int[52];\n        \n        for (int i = 0; i < s.length(); i++) {\n            char cur = s.charAt(i);\n            int index = cur <= \'Z\' ? cur - \'A\' : cur - \'a\' + 26;\n            counts[index]++;\n        }\n\n        int oddCount = 0;\n        int answer = 0;\n        \n        for (int i = 0; i < 52; i++) {\n            answer += counts[i] / 2 * 2;\n            oddCount += counts[i] & 1;\n        }\n        \n        return answer + Math.min(oddCount, 1);\n    }\n}\n```
[]