Choosing Safe Meeting Spots for a Ride-Hailing Trip
System DesignModel answerLast updated
Design a service that picks a legal, safe, and convenient meeting spot for a rider and driver, balancing walking time, driver arrival time, and confidence.
Design the algorithm and the high-level system that suggests a meeting spot for a rider and a driver in a ride-hailing app.
A rider requests a trip from an approximate location, for example inside a large building or near a busy intersection. A driver is available at a known GPS position. The system must propose a spot that the rider can walk to and the driver can legally and safely reach.
Assumptions
- You can use map data, road and pedestrian graphs, routing and ETA services, and live traffic when available.
- The rider's GPS reading can be noisy, or can fall inside a building.
- The driver must be able to stop legally and safely at the chosen spot.
- The chosen spot should balance rider walking time, driver arrival time, safety, reliability, and overall user experience.
- The result must be shown clearly in both the rider app and the driver app.
Questions you may want to raise with the interviewer
- Which environments are in scope: dense downtown, suburbs, airports, campuses, or all of them?
- Is rider mobility or accessibility information available?
- What is the maximum acceptable walk?
- Do we have data on legal stopping zones, curb access, building entrances, and past pickup outcomes?
- What are we optimizing: total trip time, cancellations, unsafe stops, or support contacts?
What to cover in your answer
- Position cleanup and map matching for rider and driver.
- Candidate generation.
- Safety and legality filtering.
- Scoring and selection.
- Architecture and data flow.
- How the result is presented, including low-confidence fallbacks.
- Learning from history and measuring success in an experiment.
Hints
Hint 1
Treat the problem as a pipeline: clean up locations, generate candidates, filter hard constraints, then rank the survivors with a weighted or learned score.
Hint 2
Keep hard constraints (legal stop, safe side of the road, no highway ramps) separate from soft trade-offs (walk time vs. driver detour). Never let a good score override a safety rule.
Hint 3
Plan for uncertainty: when the rider's location is poorly known, show a confirmation step or let the rider adjust the spot, and use past pickups to refine candidates over time.
Model answer
Medium Try it yourself first — then compare your approach, complexity and edge cases.
Framing
The goal is a spot that is legal, safe, easy to find, and cheap in total time for both parties. I would clarify scope first (assume a mixed urban setting, with airports and campuses handled by curated overrides), a default max walk of about 150-250 m (lower for users flagged as needing accessibility support), and a primary objective: minimize pickup failures (cancellations, no-shows, and unsafe stops) subject to a total-time budget.
Pipeline
1. Location cleanup
- Rider position: GPS indoors can be off by 30-100 m. Fuse GPS, Wi-Fi/cell signals, and the last known good position, and keep an uncertainty radius. If the point falls inside a building polygon, treat the building as the origin and use its entrances as walking start points.
- Map matching: Snap the rider to the pedestrian network (sidewalks, crossings, paths) and the driver to the road network using a Hidden Markov Model matcher over recent GPS traces, taking heading and speed into account.
- Driver position: Usually more reliable, but account for heading so we do not pick a spot that requires an illegal U-turn.
2. Candidate generation
Search within the walking radius around the rider's uncertainty region:
- Road-segment points sampled every 20-30 m along the curbs of nearby streets.
- Known pickup spots from history: places where past pickups completed quickly and without cancellations.
- Curated points: marked loading zones, building entrances, parking lot bays, airport and campus stands.
- The snapped original location itself, as a baseline.
Cap the list (for example 30-50 candidates) using a spatial index such as an S2 or H3 cell lookup, so the stage is fast.
3. Hard filters (safety and legality)
Remove any candidate that is:
- on a no-stopping or no-standing segment, bus lane, bike lane, tram track, or highway ramp;
- on a road class that is too fast or has no shoulder;
- inside an intersection or within a minimum distance of a crossing or corner;
- reachable only via a restricted turn or one-way violation;
- across a major road from the rider where the walking route needs an unsafe crossing;
- in a zone flagged by prior incidents or by local regulation.
Rules come from map attributes, municipal data, and learned flags. If everything is filtered out, expand the radius step by step, then fall back to the nearest legal spot and tell the rider to expect a longer walk.
4. Scoring
For each surviving candidate compute:
- Walk time from the rider's likely origin (using the pedestrian graph, crossings, stairs, and waiting at lights).
- Driver ETA and detour from the routing service with live traffic, including final-approach difficulty (turns, wrong-side arrival).
- Safety score: road speed, traffic volume, lighting, curb availability, and crossing count.
- Findability: visible landmark, distance from the entrance, and simplicity of the description.
- Historical success: completion rate, wait time, and cancellation rate at or near that spot.
- Confidence: a function of location uncertainty and data freshness.
Start with a weighted cost:
cost = a*walk + b*driver_eta + c*detour + d*(1 - safety) + e*(1 - success_rate) + f*uncertainty_penalty
Walk time should usually weigh more than equal driver time because riders are more sensitive to it, and weights should differ by context (night, rain, luggage, accessibility). Later, replace the hand-tuned weights with a ranking model (for example gradient-boosted trees) trained on pickup outcomes.
Choose the best candidate, but also keep the runner-up as an alternative.
5. Architecture
- Client apps send the request with raw location, accuracy, and device signals.
- Pickup service orchestrates the pipeline and is stateless and horizontally scalable.
- Map service: road and pedestrian graphs, restrictions, building footprints, curated points, with a spatial index.
- Routing/ETA service: walking and driving times with live traffic.
- Feature store and history store: per-spot success statistics, refreshed in batch and streaming.
- Logging pipeline: every request, candidate set, chosen spot, and outcome (arrival time, wait, cancellation, rider and driver feedback).
- Training pipeline: offline retraining of the ranker and periodic refresh of spot statistics.
Latency budget is around 200-500 ms in the request path. Precompute popular spots per area and cache walking and driving matrices for dense zones. Rerun the selection when the driver assignment changes or when the rider moves significantly.
6. Presentation and fallbacks
- Show the spot on the map with a short walking route, a landmark description ("outside the north entrance, by the pharmacy"), and the walking time.
- Show the driver the exact stop, the approach direction, and a clear statement of which side of the road to stop on.
- Allow the rider to nudge the pin within an allowed area (filtered by the same rules).
- Low confidence: ask the rider to confirm their location, or use the building entrance or the nearest high-success spot, and enable in-app chat/call.
- Update both apps live if the spot has to change, and say why.
7. Learning and experiments
- Learn from outcomes: successful, quick pickups raise a spot's score; cancellations, long waits, and driver complaints lower it. Use smoothing so sparse spots are not over-trusted, and keep a small exploration rate for new candidates.
- A/B test at the rider (or city/time-slice if drivers interact) level. Primary metrics: pickup success rate, cancellation rate, and time from arrival to pickup. Guardrails: unsafe-stop reports, support contacts, driver detour, and total trip time. Run long enough to cover weekday, weekend, and night patterns.
Trade-offs and common mistakes
- Optimizing only driver ETA leads to long walks and unsafe curbs; optimizing only walk time can lead to illegal stops.
- Trusting raw GPS when the user is indoors.
- Ignoring road-crossing and one-way constraints when computing the walking and driving paths.
- Mixing safety into the score, so that a big time saving can outvote it, instead of using hard filters.
- Treating history naively: popular spots may be popular because of past habit, not because they are good, so use outcome-based labels.
- No fallback plan for sparse map data or poor GPS.