Queues: A Tale of Two Stacks

  • + 1 comment

    With some of these challenges, I have no idea where to start and no idea how anyone else does either, like my brain isn't wired in the necessary way. I suspected this would be another example but on this occasion I'm baffled as to why this is a challenge at all. The simplistic solution below works for all test cases.

    class MyQueue(object):
        def __init__(self):
            self.queue = []
            
        
        def peek(self):
            return self.queue[0]
            
        def pop(self):
            del self.queue[0]
            
            
        def put(self, value):
            self.queue.append(value)