← Headway Interview Insights

Headway·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
Apr 2026

Summary

Headway gave me a debugging scenario involving a log parsing class, which sounds straightforward until you're staring at a TypeError and can't figure out why the speed math keeps blowing up. Three-part problem, and this was just the first piece.

Questions Asked (1)

Q1

You're given a LogEntry class that parses a whitespace-separated string. The catch_speeders function never flags any vehicle even on clearly speeding entries. Find the bug, fix it, and write a small test to confirm the time-delta math works.

Root Cause AnalysisAlgorithms & Data StructuresTechnical Trade-offs
Author's notes

Took me an embarrassingly long time to find it.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by reproducing the bug with a minimal test case, then trace the data flow from parsing to the speed calculation. Inspect the time-delta computation and unit conversions, as the bug likely lies in how timestamps are parsed or subtracted. Fix the issue and write a focused unit test that verifies the time-delta math independently.

Pro tip: Demonstrate a systematic debugging process: form a hypothesis, test it with a minimal reproduction, and verify the fix with a targeted test. This shows you can isolate and resolve issues efficiently, a key skill for production code.

1. Reproduce the Bug

Create a minimal LogEntry with clearly speeding data and run catch_speeders to confirm it fails to flag the vehicle. This establishes a baseline and ensures you understand the expected behavior.

2. Trace the Data Flow

Follow the parsed values from the LogEntry constructor through to the speed calculation. Check for incorrect parsing (e.g., timestamps as strings), unit mismatches, or integer division that could zero out the speed.

3. Inspect Time-Delta Math

Focus on how the time difference between entries is computed. Look for off-by-one errors, incorrect timestamp formats, or missing conversions (e.g., milliseconds vs. seconds).

4. Fix and Verify

Apply the fix, such as converting timestamps to a consistent unit or correcting the subtraction order. Re-run the reproduction to confirm the vehicle is now flagged.

5. Write a Unit Test

Write a small test that isolates the time-delta calculation, using known timestamps and asserting the expected difference. This prevents regressions and documents the correct behavior.

Key Points to Mention

  • Reproduce the bug with a minimal test case before attempting a fix.
  • Check for unit mismatches (e.g., seconds vs. milliseconds) in timestamp parsing.
  • Beware of integer division truncating speed to zero.
  • Ensure timestamps are parsed as numeric types, not strings.
  • Verify the order of subtraction for time delta (later minus earlier).
  • Write a focused unit test for the time-delta math to confirm the fix.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.