← Questions

Add one delivery center to minimize the worst distance

0
AmazonCodingLast asked Sep 2026

A grid marks delivery centers with 1 and every other cell with 0. The distance between two cells is max(|x1 - x2|, |y1 - y2|) (moving in all eight directions). The grid's inconvenience is the largest distance from any 0 cell to its nearest center. You may turn at most one 0 into a new center. Return the smallest inconvenience you can reach.

Write and test your solution herePython in your browser, the question's tests level by level, every submission kept for you.Sign in to start coding