← 返回 sofi 的题目列表Highway Sensor Journey Count
类型:qbank
Karat practical coding task with highway sensor logs: debug an existing test, then count completed entry-to-exit journeys by vehicle.
Requirements
The domain has highway entrances, exits, and intermediate checkpoints.
Each location has a sensor that records when a car passes.
Input logs are sorted by time and include timestamp, sensor, and car identifier.
Part 1: inspect given code and tests, then debug why a test is failing.
Part 2: write a function that counts how many journeys appear in a log segment.
A journey is completed when the same car goes from an entry sensor to an exit sensor.
Notes
Track per-car state rather than only aggregate counts.
Clarify how to treat duplicate entries, missing exits, exits without prior entries, and checkpoint-only observations.