Queue
Python data engineering interview problem. Difficulty: intermediate. Pattern: Stacks. About 14 minutes. Part of the Pro drill bank.
Implement a Queue with enqueue, dequeue, front, and empty. Treat this as a production helper: match the contracted return shape, including empty and duplicate inputs.
A queue models arrival order, such as print jobs waiting for a worker. The first item added must be the first item removed. Implement a Queue class with enqueue, dequeue, front and empty. dequeue removes the oldest value, while front reads it without removing it. Write class Queue. After enqueueing 1 and 2, dequeue returns 1 and the next front is 2. The starter file already declares the class shape and harness prints. Keep the class name, method names and print lines, and fill in the methods.
Requirements
- Add new values at the back.
- Remove and return the oldest value.
- Keep front non-mutating and return a boolean from empty.
Constraints
- The queue starts empty and method names must match the harness.
- Return values in first-in, first-out order.
Examples
Input: Queue enqueue 1,2; dequeue; front Output: 1 then 2 FIFO order.
Topics: lakebench, python, queue, class.
More Python interview questions · All interview problems · Learn data engineering
Queue
Interview-style drill: Implement a Queue with enqueue, dequeue, front, and empty.
Implement class `Queue` with `enqueue(x)`, `dequeue()` (return value), `front()`, and `empty()` → bool. Keep the harness prints.