题目:原题链接(简单)
标签:字符串、哈希表
解法 | 时间复杂度 | 空间复杂度 | 执行用时 |
Ans 1 (Python) | O ( N ) | O ( N ) | 40ms (67.47%) |
Ans 2 (Python) | |||
Ans 3 (Python) |
解法一:
class Solution:
def canPermutePalindrome(self, s: str) -> bool:
lst = set()
for ch in s:
if ch not in lst:
lst.add(ch)
else:
lst.remove(ch)
return len(lst) <= 1