easy quick python code,beat 91.08%


  • 0
    Q
    # code block
    class Solution(object):
        def longestPalindrome(self, s):
        """
        :type s: str
        :rtype: int
        """
        length = 0
        for i in set(s):
            if s.count(i) % 2 == 0:
                length += s.count(i)
            else:
                length += s.count(i) - 1
        if len(s) != length:
            length += 1
        return length

Log in to reply
 

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