Loading...

The Queue Disguise

A medium Python interview practice problem on DataDriven. Write and execute real python code with instant grading.

Domain
Python
Difficulty
medium
Seniority
mid, senior

Problem

A systems design exercise requires implementing a first-in-first-out queue using only two stacks (Python lists), without using any queue library. Implement push, pop, peek, and empty operations. The amortized time for each operation should be O(1).

Practice This Problem

Solve this Python problem with real code execution. DataDriven runs your Python code in a sandboxed Docker environment and grades it instantly.