Ambulance Optimal Route Grid Dispatch
Ambulance Optimal Route Grid Dispatch
Pune's emergency dispatch center receives multiple accident alerts simultaneously across the city. Given hospital and incident coordinates on a city grid, find the minimum total distance ambulances must travel collectively. Rule: each incident is served by its nearest hospital (Manhattan distance). Return the total distance over all incidents. Your solve(...) function receives the inputs as ready-made arguments — no input reading or parsing needed; just return the answer.
Approach
Given hospital positions and incident coordinates in 2D grid, find minimum total Manhattan distance.
Input
Output
More Arrays problems
Browse all coding problems →Press Run to test your custom input, or Submit to judge against all test cases.
Sign in to continue
Create a free account to run code, submit solutions and track progress.
- Free forever — no credit card
- 10+ languages with live execution
- Points, streaks & leaderboards