Python O(n) time using hashmap with explanation
Essentially we want to counting pairs, plus one if there is another non-pair character aka\nlongestPlindrome = 2*numPairs + 1 if 2*numPairs < len(s) (the extra 
Essentially we want to counting pairs, plus one if there is another non-pair character aka\n`longestPlindrome = 2*numPairs + 1 if 2*numPairs < len(s)` (the extra 1 is because a single character can go in the middle)\nWe have two options:\n1. sort with potentially no extra space but `O(nlogn)` time\n2. use a hashmap -> a bit extra space but` O(n)` time\n\nI choose option 2 because at maximum the hashmap size is bounded at `O(56)` due to the string only containing lower and upper case letters(26*2), so essentially it is `O(1)` extra space. On large inputs we would save a lot of time with option 2 with no extra cost in space.\n\n```\nclass Solution:\n    def longestPalindrome(self, s: str) -> int:\n        pairsCount = 0\n        charMap = Counter(s)\n        n = len(s)\n        for c in charMap:\n            pairsCount += charMap[c] // 2\n        palindromeLength = pairsCount * 2\n        if palindromeLength < n:\n            palindromeLength += 1\n        return palindromeLength\n```
[]