2 lines in Python


  • 2
    class Solution(object):
        def longestPalindrome(self, s):
            c = collections.Counter(s)
            return sum(v - 1 * (v % 2 != 0) for v in c.values()) + 1 * any(v % 2 != 0 for v in c.values())
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.