Skip to content

Latest commit

 

History

History
46 lines (26 loc) · 601 Bytes

266._Palindrome_Permutation.md

File metadata and controls

46 lines (26 loc) · 601 Bytes

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