InterviewDB Experience

Pair Programming: Debug and Extend a Live Codebase Collaboratively Under Time Pressure

Interview Experience

Problem

The interviewer shares a partially implemented task scheduler (roughly 150 lines of Python). It has 3 known failing tests and 2 undocumented bugs. You will pair-program live: read the code, diagnose failures, fix them, and add a new cancel_task feature — all within 45 minutes.

The scheduler interface:

python
class TaskScheduler:
    def schedule(self, task_id: str, delay_sec: int, fn: Callable) -> None: ...
    def cancel(self, task_id: str) -> bool: ...
    def get_pending(self) -> list[str]: ...

Failing tests hint at:
- A race condition when two tasks are scheduled for the same time
- cancel returning True for already-executed tasks
- get_pending including tasks that errored during execution

Follow-ups

  1. How do you approach reading unfamiliar code quickly — what do you look at first?
  2. The race condition is in a heap push/pop. How do you make the heap thread-safe?
  3. How would you add retry logic with exponential backoff for failed tasks?
  4. If you needed to persist the task queue across restarts, what would you change?

Full Details

Problem

The interviewer shares a partially implemented task scheduler (roughly 150 lines of Python). It has 3 known failing tests and 2 undocumented bugs. You will pair-program live: read the code, diagnose failures, fix them, and add a new cancel_task feature — all within 45 minutes.

The scheduler interface:

python
class TaskScheduler:
    def schedule(self, task_id: str, delay_sec: int, fn: Callable) -> None: ...
    def cancel(self, task_id: str) -> bool: ...
    def get_pending(self) -> list[str]: ...

Failing tests hint at:
- A race condition when two tasks are scheduled for the same time
- cancel returning True for already-executed tasks
- get_pending including tasks that errored during execution

Follow-ups

  1. How do you approach reading unfamiliar code quickly — what do you look at first?
  2. The race condition is in a heap push/pop. How do you make the heap thread-safe?
  3. How would you add retry logic with exponential backoff for failed tasks?
  4. If you needed to persist the task queue across restarts, what would you change?

About This Question

This is a candidate experience report from a circle interview during the onsite round.

It covers the following topics: Coding, Queue, Heap, Onsite .