Design Google Maps: How Does It Reroute When You Miss a Turn?
What the video says
You miss your turn, and Google Maps already has a new route. How does it find one that fast?
In an interview, I'd start with the map as a graph. Every junction is a dot, every road is a line, and every line has a drive time. A route is the cheapest chain.
Your phone keeps snapping its GPS position to the route. When the dot lands on a different road, you are off route, so it asks for a new route from where you are now.
How do you search? Turning around just takes you back, and that is often slower. Searching every road floods the whole map. So aim the search at the destination, and use shortcuts worked out in advance.
And drive times are live. A jam ahead makes its roads expensive, so the same search steers around it.
Google has published two pieces of this. In 2020 it said Maps reroutes you automatically using nearby road conditions. In 2021 its researchers wrote that an exhaustive search takes seconds, too slow.
So that's the design I'd explain. A graph of roads, a check that you're still on route, a search aimed at the destination, and live drive times.
Follow for the next system. Next time, who gets the last item on Amazon?
Sources
Every fact in the video was checked against these when it was made.