• + 0 comments
    class Solution:
        # Write your code here
        def __init__(self):
            # We only need one stack/queue buffer
            self.my_buffer = []
            
        def pushCharacter(self, c):
            # Build the buffer here
            self.my_buffer.append(c)
            
        def enqueueCharacter(self, c):
            # Don't bother building a queue
            pass
            
        def popCharacter(self) -> str:
            # Pop the buffer from the end
            return self.my_buffer.pop()
            
        def dequeueCharacter(self) -> str:
            # Pop the buffer from the front
            return self.my_buffer.pop(0)