Skip to content

266 Palindrome Permutation

266. Palindrome Permutation

题目: https://leetcode.com/problems/palindrome-permutation/

难度 : Easy

思路:

hint 已经提示的很明显。数单字个数来处理

AC代码

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

        for char in s:
            lookup[char] = lookup.get(char,0) + 1

        res = 0

        for char, cnt in lookup.items():
            if cnt % 2 == 0 :
                continue
            else:
                res += 1

        return res < 2



回到顶部