• + 0 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]