Closest Stop
Find the index of the nearest bus stop to a pothole on a sorted route.
Stop positions (sorted, comma-separated)
Pothole position
Closest stop index
—
Proof
Enter a sorted list of stop positions and a pothole location to see the result.
Binary search finds the insertion point, then picks the nearer neighbor — ties go to the smaller index.