Simple Java Solution in One Pass
Count duplicates in the pass, then check if we have an extra character to fix in the middle.\n\npublic int longestPalindrome(String s) {\n        boolean[] map 
Count duplicates in the pass, then check if we have an extra character to fix in the middle.\n```\npublic int longestPalindrome(String s) {\n        boolean[] map = new boolean[128];\n        int len = 0;\n        for (char c : s.toCharArray()) {\n            map[c] = !map[c];         // flip on each occurrence, false when seen n*2 times\n            if (!map[c]) len+=2;\n        }\n        if (len < s.length()) len++; // if more than len, atleast one single is present\n        return len;\n    }\n```
[]