You are viewing a single comment's thread. Return to all comments →
def init(self): self.stack = [] self.queue = []
def pushCharacter(self, char): self.stack.append(char) def enqueueCharacter(self, char): self.queue.append(char) def popCharacter(self): if len(self.stack) == 0: return None return self.top() self.stack = self.stack[:-1] def top(self): if len(self.stack) == 0: return None return self.stack[-1] def dequeueCharacter(self): if len(self.queue) == 0: return None return self.front() self.queue = self.queue[1:] def front(self): if len(self.queue) == 0: return None return self.queue[0]
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 →
def init(self): self.stack = [] self.queue = []