Implement a Queue using Stacks
Medium
Implement a queue using the stack data structure. Include the following functions:
enqueue(x: int) -> None: addsxto the end of the queue.dequeue() -> int: removes and returns the element from the front of the queue.peek() -> int: returns the front element of the queue.
You may not use any other data structures to implement the queue.
Example
Input: [enqueue(1), enqueue(2), dequeue(), enqueue(3), peek()]
Output: [1, 2]
Constraints:
- The
dequeueandpeekoperations will only be called on a non-empty queue.