Java beats 100%
Java beats 100%\n\n\n\n# Code\n\nclass Solution {\n    public int longestPalindrome(String s) {\n        int[] array = new int[58];\n        int count = 0,odd =
Java beats 100%\n![image.png](https://assets.leetcode.com/users/images/9cec8b26-d985-4b33-9635-df2a72930861_1717462789.8276665.png)\n\n\n# Code\n```\nclass Solution {\n    public int longestPalindrome(String s) {\n        int[] array = new int[58];\n        int count = 0,odd = 0;\n\n        for(char each : s.toCharArray()){\n            array[each - \'A\']++;\n        }\n\n        for(int each : array){\n            if(each % 2 == 0 && each != 0){\n                count += each;\n            }else if(each % 2 == 1 && each != 1){\n                count += each -1; \n                odd = 1;\n            }else if(each == 1){\n                odd = 1;\n            }\n        }\n\n        return count + odd;\n    }\n}\n```
['Java']