Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """
- -> Direct Push In Stack One
- -> When Called Pop If Stack Two Is Empty Load All Stack One Elements In Stack Two Else
- Pop From Stack Two
- """
- class Queue:
- def __init__(self):
- self.OneStack = []
- self.TwoStack = []
- def Push(self, Val):
- self.OneStack.append(Val)
- def Pop(self):
- if(self.TwoStack):
- print(self.TwoStack.pop())
- else:
- while(self.OneStack):
- self.TwoStack.append(self.OneStack.pop())
- print(self.TwoStack.pop())
- def Top(self):
- print(self.TwoStack[-1])
- ObjQueue = Queue()
- ObjQueue.Push(1)
- ObjQueue.Push(2)
- ObjQueue.Push(4)
- ObjQueue.Pop()
- ObjQueue.Pop()
- ObjQueue.Pop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement