# https://www.hackerrank.com/challenges/ctci-queue-using-two-stacks
# Python 3


class MyQueue(object):
    def __init__(self):
        self.enqueue = []
        self.dequeue = []

    def peek(self):
        if len(self.dequeue) > 0:
            return self.dequeue[0]

    def pop(self):
        while len(self.enqueue) > 0:
            self.dequeue.append(self.enqueue.pop())
        if len(self.dequeue) > 0:
            return self.dequeue.pop()

    def put(self, value):
        self.enqueue.append(value)

queue = MyQueue()
t = [
   '1 42',
   '2',
   '1 14',
   '3',
   '1 28',
   '3',
   '1 60',
   '1 78',
   '2',
   '2',
]
for line in t:
    values = map(int, line.split())
    values = list(values)
    if values[0] == 1:
        queue.put(values[1])
    elif values[0] == 2:
        queue.pop()
    else:
        print(queue.peek())

# queue = MyQueue()
# t = int(input())
# for line in range(t):
#     values = map(int, input().split())
#     values = list(values)
#     if values[0] == 1:
#         queue.put(values[1])
#     elif values[0] == 2:
#         queue.pop()
#     else:
#         print(queue.peek())


@@ -73,17 +73,16 @@
 thon 3%0A%0A
-%0A
 class My
@@ -181,20 +181,44 @@
     def 
-peek
+_transfer_enqueue_to_dequeue
 (self):%0A
@@ -217,34 +217,37 @@
 (self):%0A        
-if
+while
  len(self.dequeu
@@ -232,34 +232,34 @@
  while len(self.
-d
 e
+n
 queue) %3E 0:%0A    
@@ -270,30 +270,47 @@
     
-return 
+self.dequeue.append(
 self.
-d
 e
+n
 queue
-%5B0%5D
+.pop())
 %0A%0A  
@@ -316,18 +316,19 @@
    def p
-op
+eek
 (self):%0A
@@ -339,49 +339,120 @@
     
-while len(self.enqueue) %3E 0:%0A       
+if not self.dequeue:%0A            self._transfer_enqueue_to_dequeue()%0A        value = self.dequeue.pop()%0A
      
+   
 self
@@ -471,60 +471,156 @@
 end(
-self.enqueue.pop())%0A        if len(self.dequeue) %3E 0
+value)%0A        return value%0A%0A    def pop(self):%0A        if not self.dequeue:%0A            self._transfer_enqueue_to_dequeue()%0A        if self.dequeue
 :%0A  
@@ -654,16 +654,54 @@
 ue.pop()
+%0A        else:%0A            return None
 %0A%0A    de

Solve problem of implementing a queue using two stacks