Python Solution beats 98.17% and run time: 29ms


  • 0
    A

    class Solution(object):
    def canPermutePalindrome(self, s):
    """
    :type s: str
    :rtype: bool
    """
    dict = {}
    for val in s:
    dict[val] = dict.get(val,0) + 1

        for val in dict.keys():
            if dict[val] % 2 == 0:
                del dict[val]
        
        if len(dict) == 1 or len(dict) == 0:
            return True
        else:
            return False

Log in to reply
 

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