We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
python3importsysfromcollectionsimportdequeclassSolution:def__init__(self):self.items=deque()#define Queue specific methodsdefenqueueCharacter(self,item):self.items.append(item)defdequeueCharacter(self):ifnotself.is_empty():returnself.items.popleft()defis_empty(self):#createacheckforemptyQueue/Stackreturnlen(self.items)==0#define Stack specific methodsdefpushCharacter(self,item):self.items.append(item)defpopCharacter(self):ifnotself.is_empty():returnself.items.pop()
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Day 18: Queues and Stacks
You are viewing a single comment's thread. Return to all comments →