Machine coding round
Ride Booking Driver Matching Coding Problem
What this interview round tests
The ride booking system is the Uber/Ola question of Indian machine coding rounds — and beneath the map pins it is a resource-allocation problem: riders request, a pool of drivers is available, and the system must pick the right driver, assign them exclusively, and give them back when things change. The same select–assign–release loop runs delivery-partner dispatch, support-agent routing, and warehouse task allocation, which is why interviewers keep reaching for it.
What actually gets graded is discipline in three places. Selection must be deterministic: "nearest available driver" needs an explicit tie-break, or your matching depends on hash-map iteration order and fails intermittently. Assignment must be exclusive: an assigned driver is unavailable everywhere, instantly. And release must be complete: a cancelled ride returns its driver to the pool, every time — leaked drivers are the bug that quietly empties a dispatch system.
The scenario
You are handed the matching service of a ride-hailing backend: riders request rides, drivers register availability, candidate drivers are ranked, one is assigned, and rides complete or cancel. The flow exists end to end, and the test suite fails it in the ways real dispatch systems fail.
Equidistant drivers are picked differently run to run, an assigned driver gets matched to a second ride, cancelled rides never return their driver to the pool, completing a ride leaves the driver stuck in "on trip", and unknown riders and drivers slip through validation. Your job is to make matching deterministic and the driver lifecycle airtight.
What you’ll practice
- Candidate selection: filtering availability and ranking with explicit criteria
- Deterministic tie-breaking so equal candidates always resolve the same way
- Exclusive assignment: a matched driver is atomically removed from the pool
- Release-on-cancel and release-on-complete as first-class transitions
- Driver availability as a state machine: available → assigned → on trip → available
- Validation and clear errors for unknown entities and illegal requests
How to approach it
Write the ranking as one explicit comparator — primary criterion, then a stable tie-break like driver id — and select through it every time. Determinism is graded here because it is what makes dispatch debuggable in production: the same pool and the same request must always produce the same match.
Then treat assignment and release as paired transitions on the driver, not side effects of the ride: matching flips the driver out of the available pool in the same step that binds them to the ride, and every ride exit path — completion, rider cancel, driver cancel — flips them back. Enumerate the exit paths and make each one release; the tests will walk a driver through the full cycle and re-request them immediately.
The starter repository ships with a failing test suite and a bundled verify.sh. Reviewed reference solutions are part of Gronex Pro — this page stays spoiler-free on purpose.
FAQ
Is this the Uber low-level design interview question?
It is the gradeable core of it: candidate selection, exclusive assignment, and release-on-cancel as working code. The geo-indexing and surge-pricing halves of "design Uber" are system design conversation; this is the part you can implement and be tested on in a machine coding round.
Why do interviewers care so much about tie-breaking?
Because "two drivers at the same distance" is guaranteed to happen, and a system that picks one arbitrarily is untestable and unexplainable. An explicit, stable tie-break is a one-line signal that you design for determinism — evaluators test it with equidistant candidates on purpose.
Does this problem involve real geo-location math?
No — distances and availability are modelled simply so the logic under test is selection, assignment, and lifecycle, not haversine formulas. That mirrors the interview: the matching discipline is what gets graded, and it is what the bundled test suite checks in Java, Python, or C++.