题目描述
blablabla
样例
class Solution:
res = []
memo = {}
def firstAppearingOnce(self):
"""
:rtype: str
"""
for ch in self.res:
if self.memo[ch] == 1:
return ch
return "#"
def insert(self, char):
"""
:type char: str
:rtype: void
"""
if char not in self.memo:
self.memo[char] = 1
else:
self.memo[char] + 1
# 这句等效于
# self.memo[char] = 1 if char not in self.memo else self.memo[char] + 1
# 此处没有+=1 因为else后面是do
self.res.append(char)