PYTHON - 35ms 99th percentile O(n) solution
\n\nclass Solution(object):\n\n    def longestPalindrome(self, s):\n        """\n        :type s: str\n        :rtype: int\n        """\n        ctmap = {}\n   
\n\nclass Solution(object):\n\n    def longestPalindrome(self, s):\n        """\n        :type s: str\n        :rtype: int\n        """\n        ctmap = {}\n        for c in s:\n            if c not in ctmap:\n                ctmap[c] = 1\n            else:\n                ctmap[c] += 1\n\n        ret = 0\n        singleCharFound = 0\n        for key in ctmap:\n            if ctmap[key] % 2 == 0:\n                ret += ctmap[key]\n            else:\n                ret += ctmap[key] - 1\n                singleCharFound = 1\n        \n        return ret + singleCharFound
[]