題目描述
請實現一個函數用來找出字符流中第一個只出現一次的字符。例如,當從字符流中只讀出前兩個字符"go"時,第一個只出現一次的字符是"g"。當從該字符流中讀出前六個字符“google"時,第一個只出現一次的字符是"l"。
class Solution:
# 返回對應char
def FirstAppearingOnce(self):
# write code here
def Insert(self, char):
# write code here
class Solution:
def __init__(self):
self.my_list = []
def FirstAppearingOnce(self):
for i in self.my_list:
if self.my_list.count(i) == 1:
return i
return "#"
def Insert(self, char):
self.my_list.append(char)