Design Toll Calculation

Medium35 min
1 / 30
understanding9 min read

Problem Statement: Itemized Toll on Any Route

Problem Statement: Itemized Toll on Any Route — toll calculation interview depth

Problem Statement: Itemized Toll on Any Route

Phase understanding — Navigation apps must show per-segment tolls before the driver commits, then reconcile after GPS proves the path taken.

ConcernDecision
1Itemized Toll on Any Route
2Agency graph ingest with OpenLR segment validation
3Quote API returns itemized segments + confidence band
4Post-trip reconciliation ledger separate from cache

Design note (1)

A strong answer explains map-match confidence propagating into pricing bands instead of a single misleading dollar amount. Watch for candidates who return one opaque total without segment[] breakdown or rate_card_version.

Operations: Page when quote p95 > 300ms for 10 minutes or reconciliation delta > 2% vs agency sample.

Edge cases: Cross-border route (US→CA) applies currency split; tunnel GPS loss must not zero-out known gantry fees; reroute after quote issues toll_delta event not silent overwrite.

javaOne Dark Pro
1public record TollQuote(String quoteId, long totalCents, String rateCardVersion, boolean staleRateCard) {}
pythonOne Dark Pro
1def segment_cents(distance_m: float, rate_per_km: float, min_cents: int) -> int:
2 return max(min_cents, int(round(distance_m / 1000.0 * rate_per_km)))
typescriptOne Dark Pro
1export interface TollSegmentLine { agencyId: string; plazaId: string; cents: number; confidence: number; }

Why interviewers care

Toll Calculation interviews reward crisp scope, explicit trade-offs, and failure stories—not generic microservice diagrams.

Interview checkpoint

Name one failure story for Problem Statement: Itemized Toll on Any Route that proves you understand real outages, not happy-path diagrams.

Key Highlights

  • Navigation apps must show per-segment tolls before the driver commits, then reconcile after GPS proves the path taken.
  • Agency rate cards versioned with effective timestamps
  • Itemized segment breakdown with confidence
  • Degrade with stale_rate_card flag, never silent zero
pro tip
For Problem Statement: Itemized Toll on Any Route, state agency versioning before storage.
interviewer loves
Quantified toll breakdown with rate_card_version on every quote.
common mistake
Returning one total without segment lines or stale flags.
trade off
Precomputed OD pairs vs online graph walk on reroutes.

Section Rescue Kit

Buzzwords to use:

OpenLRToll graph

Safe statements:

  • "For Problem Statement: Itemized Toll on Any Route, I'll separate quote cache from financial ledger before naming databases."
  • "Immutable route snapshot makes disputes reproducible line by line."
Design Toll Calculation - System Design | WinJob | WinJob