Straight forward 2-line python solution


  • 0
    P

    class Solution:
    def longestPalindrome(self, s):
    """
    :type s: str
    :rtype: int
    """
    r = 2*sum(s.count(n)//2 for n in set(s))
    return r+1 if r < len(s) else r


Log in to reply
 

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