← 返回 doordash 的题目列表Debugging: Dasher Map (HashMap init / NullPointer / key swap bugs)
类型:online_judge
Problem: Debug the Dasher Map Module
You are given code and unit tests (provided by the interviewer) for a Dasher real-time map module. The system is "randomly" failing. You must identify and fix the bugs so that all tests pass.
Known symptoms (from the interview notes)
Mis-configured HashMap initialization.
NullPointer errors.
Buggy key swapping causing inconsistent reads/writes.
Your tasks
Use logs/stack traces/failing tests to find root causes.
Fix data structure initialization and null handling.
Fix inconsistent key usage (e.g., lat/lng, dasherId/orderId, or map key/value swapped).
Add at least 2 additional test cases that cover the fix and prevent regression.
Output
Briefly describe the fixes.
Provide the key patched code snippets and the new tests (any language; pseudocode acceptable).
Example
Input
UpdateLocation(dasherId=1, lat=37.7, lng=-122.4) then GetLocation(1)
Output
returns (37.7, -122.4) without exception