The Queue Disguise
A medium Python mock interview question on DataDriven. Practice with AI-powered feedback, real code execution, and a hire/no-hire decision.
- Domain
- Python
- Difficulty
- medium
- Seniority
- L4
Interview Prompt
Implement a FIFO queue class `MyQueueFromStacks` using two stacks (Python lists), supporting `push(x)`, `pop()` (remove and return the front value), `peek()` (return the front value without removing), and `empty()` (return a bool). Then write a top-level driver `run_queue_operations(operations, args)` that the test harness calls. `operations` is a list of strings: the first entry is always `"MyQueueFromStacks"` (construct a fresh queue), and each later entry is one of `"push"`, `"pop"`, `"peek"`, or `"empty"`. `args` is a parallel list of argument lists (e.g. `[1]` for a push, `[]` for the others). Replay the operations in order and return a list parallel to `operations`: `None` for the constructor and for each `push`, the returned value for each `pop`/`peek`, and a `True`/`False` bool for each `empty`. Inputs are well-formed: `pop`/`peek` are never called on an empty queue.
Summary
A queue in sheep's clothing.
How This Interview Works
- Read the vague prompt (just like a real interview)
- Ask clarifying questions to the AI interviewer
- Write your python solution with real code execution
- Get instant feedback and a hire/no-hire decision