Debugging Exercise: “Pick Dasher”
You are given a small codebase for selecting a dasher (driver) using a heap/priority-queue–like structure.
The current implementation is failing tests / behaving incorrectly. While debugging, you notice issues such as:
-
A required
constructor
was not implemented/initialized properly.
-
A method similar to
adjustKey()
has an
off-by-one
bug: it uses something like
size - 1
when
size
is already the correct last index (or vice versa).
Tasks
-
Identify and fix the bug(s) so the selection logic works correctly.
-
Write your own
test cases
that reproduce the failure and verify the fix.
Follow-up (production readiness)
If this were production code, what changes would you make beyond the minimal bug fix? Consider:
-
input validation
-
error handling
-
logging/metrics
-
performance
-
maintainability (API design, naming, invariants, documentation)
-
test strategy (unit/integration/property-based)
-
rollout safety (feature flags, canary)