题解 | #字符流中第一个不重复的字符#
字符流中第一个不重复的字符
https://www.nowcoder.com/practice/00de97733b8e4f97a3fb5c680ee10720
# -*- coding:utf-8 -*-
class Solution:
def __init__(self) -> None:
self.s = ""
self.mp = {}
def FirstAppearingOnce(self):
for c in self.s:
if self.mp[c] == 1:
return c
return '#'
def Insert(self, char):
self.s += char
if char in self.mp:
self.mp[char] += 1
else:
self.mp[char] = 1
