InterviewDB Experience

Engine Utilization: Compute and Report Resource Utilization Across Processing Engines

Interview Experience

Round 1 Coding

Problem

You have a pool of processing engines. Each engine receives tasks over time. Given a log of (engine_id, task_id, start_time, end_time), compute each engine's utilization percentage over a specified observation window, and identify idle periods longer than a threshold.

python
def engine_utilization(
    logs: list[tuple[str, str, int, int]],
    window_start: int,
    window_end: int
) -> dict[str, float]:

**returns** {engine_id: utilization_percent} for the window
    ...

def find_idle_periods(
    logs: list[tuple[str, str, int, int]],
    engine_id: str,
    min_idle: int
) -> list[tuple[int, int]]:

**returns** list of (start, end) idle intervals >= min_idle
    ...

Example

logs = [
  ("E1", "T1", 0, 30),
  ("E1", "T2", 50, 80),
  ("E2", "T3", 10, 90),
]
engine_utilization(logs, 0, 100)
# E1: 30+30=60 busy out of 100 -> 60.0%
# E2: 80 busy out of 100       -> 80.0%
# -> {"E1": 60.0, "E2": 80.0}

find_idle_periods(logs, "E1", min_idle=15)
# -> [(30,50)]  gap of 20 units >= 15

Follow-ups

  1. What if task intervals overlap for the same engine — how do you merge them before computing utilization?
  2. How would you detect which engine is the bottleneck (highest utilization) in a pipeline?
  3. How would you visualize utilization as a Gantt chart in ASCII output?
  4. How does your solution scale when logs contain millions of records?

Full Details

Round 1 Coding

Problem

You have a pool of processing engines. Each engine receives tasks over time. Given a log of (engine_id, task_id, start_time, end_time), compute each engine's utilization percentage over a specified observation window, and identify idle periods longer than a threshold.

python
def engine_utilization(
    logs: list[tuple[str, str, int, int]],
    window_start: int,
    window_end: int
) -> dict[str, float]:

**returns** {engine_id: utilization_percent} for the window
    ...

def find_idle_periods(
    logs: list[tuple[str, str, int, int]],
    engine_id: str,
    min_idle: int
) -> list[tuple[int, int]]:

**returns** list of (start, end) idle intervals >= min_idle
    ...

Example

logs = [
  ("E1", "T1", 0, 30),
  ("E1", "T2", 50, 80),
  ("E2", "T3", 10, 90),
]
engine_utilization(logs, 0, 100)
# E1: 30+30=60 busy out of 100 -> 60.0%
# E2: 80 busy out of 100       -> 80.0%
# -> {"E1": 60.0, "E2": 80.0}

find_idle_periods(logs, "E1", min_idle=15)
# -> [(30,50)]  gap of 20 units >= 15

Follow-ups

  1. What if task intervals overlap for the same engine — how do you merge them before computing utilization?
  2. How would you detect which engine is the bottleneck (highest utilization) in a pipeline?
  3. How would you visualize utilization as a Gantt chart in ASCII output?
  4. How does your solution scale when logs contain millions of records?

About This Question

This is a candidate experience report from a samsara interview during the phone round.

It covers the following topics: Coding, Onsite, Phone .