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.
classSolution:# Write your code heredef__init__(self):# We only need one stack/queue bufferself.my_buffer=[]defpushCharacter(self,c):# Build the buffer hereself.my_buffer.append(c)defenqueueCharacter(self,c):# Don't bother building a queuepassdefpopCharacter(self)->str:# Pop the buffer from the endreturnself.my_buffer.pop()defdequeueCharacter(self)->str:# Pop the buffer from the frontreturnself.my_buffer.pop(0)
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 →