Python solution


  • 1
    Y
    from collections import defaultdict
    class Solution(object):
        def canPermutePalindrome(self, s):
            """
            :type s: str
            :rtype: bool
            """
            d=defaultdict(int)
            for c in s:
                d[c]^=1
            return sum(d.itervalues())<=1

Log in to reply
 

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