54.字符流中第一个不重复的字符(python)
题目描述
请实现一个函数用来找出字符流中第一个只出现一次的字符。例如,当从字符流中只读出前两个字符"go"时,第一个只出现一次的字符是"g"。当从该字符流中读出前六个字符“google"时,第一个只出现一次的字符是"l"。
输出描述:
如果当前字符流没有存在出现一次的字符,返回#字符。
class Solution:
# 返回对应char
def __init__(self):
self.stack=[]
def FirstAppearingOnce(self):
# write code here
for e in self.stack:
if self.stack.count(e)==1:
return e
return "#"
def Insert(self, char):
# write code here
self.stack.append(char)2020-01-01 15:58:47
相关推荐
cakecc00 2020-11-06
世事一场大梦 2020-11-17
wangzhaotongalex 2020-10-20
rechanel 2020-11-16
luofuIT成长记录 2020-09-22
周游列国之仕子 2020-09-21
PYTandFA 2020-09-15
taomengxing 2020-09-07
MaggieRose 2020-08-19
kevinweijc 2020-08-18
earthhouge 2020-08-18
yonggeno 2020-08-18
jyj00 2020-08-15
CXsilent 2020-08-12
amberom 2020-08-03
yiyilanmei 2020-08-03
纬纬 2020-07-31
zhuyonge 2020-07-26