在字符串 s 中找出第一个只出现一次的字符。如果没有,返回一个单空格。
示例:
s = "abaccdeff"
返回 "b"
s = ""
返回 " "
可以活用python字典。
class Solution:
def firstUniqChar(self, s: str) -> str:
numdic = dict()
for c in s:
if c in numdic:
numdic[c] += 1
else:
numdic[c] = 1
for i in numdic:
if numdic[i] == 1:
return i
return " "