Python Solution


  • 0
    P

    class Solution(object):
    def canPermutePalindrome(self, s):
    """
    :type s: str
    :rtype: bool
    """

        global_dict = {}
        
        for i in s:
            if i not in global_dict.keys():
                global_dict[i] = 0
            else:
                del global_dict[i]        
        
        if(len(s) % 2 == 0):
             if(len(global_dict)):
                return False
        else:
            if(len(global_dict) > 1):
                return False
        return True

Log in to reply
 

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