调用 collections.Counter 对 字符串进行计数,然后统计 count 中是否有不为 1 的字符
#
# 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
#
#
# @param str string字符串
# @return bool布尔型
#
from collections import Counter
class Solution:
def isUnique(self , s: str) -> bool:
# write code here
count = Counter(s)
for k, v in count.items():
if v != 1:
return False
return True