classSolution:deffirstUniqChar(self, s:str)->str:
dic ={}for c in s:
dic[c]=not c in dic #not c in dic 整体为一个布尔值,c in dic 为判断字典中是否含有键c for c in s:if dic[c]:return c
return' '
第一个只出现一次的字符在字符串 s 中找出第一个只出现一次的字符。如果没有,返回一个单空格。 s 只包含小写字母。s = "abaccdeff"返回 "b"s = "" 返回 " "哈希表的使用,代码如下:class Solution: def firstUniqChar(self, s: str) -> str: dic = {} for c in s: dic[c] = not c in dic #not c i