Hi,
I completed this challenge using below solution. I also made a change on stack class, within pop() function, such that first element is popped from stack, which is in an array, instead of last element.
from Stack import MyStack
Push Function => stack.push(int) //Inserts the element at top
Pop Function => stack.pop() //Removes and returns the element at top
Top/Peek Function => stack.get_top() //Returns top element
Helper Functions => stack.is_empty() & stack.isFull() //returns boolean
class NewQueue:
def init(self):
self.main_stack = MyStack()
# Write your code here
# Inserts Element in the Queue
def enqueue(self, value):
self.main_stack.push(value)
return True
# Removes Element From Queue
def dequeue(self):
return self.main_stack.pop()