题目描述:
在字符串 s 中找出第一个只出现一次的字符。如果没有,返回一个单空格。 s 只包含小写字母。
示例:
输入:s = “abaccdeff”
输出:‘b’
题解:运用哈希表来解决,哈希集合解决不了。
class Solution:
def firstUniqChar(self, s: str) -> str:
dic = {
}
for i in s:
if i in dic:
dic[i] = False
else:
dic[i] = True
for i in s:
if dic[i]:
return i
return " "