Challenge: Implement Queue Using Stacks
Try to solve the Implement Queue Using Stacks problem.
We'll cover the following
Statement
Design a queue data structure using only two stacks and implement the following functions:
enqueue(int x)
: Inserts a value to the back of the queue.dequeue()
: Removes and returns the value from the front of the queue.
Constraints:
-
x
Examples
Create a free account to view this lesson.
Continue your learning journey with a 14-day free trial.
By signing up, you agree to Educative's Terms of Service and Privacy Policy