Minimize Maximum Chebyshev Distance by Adding One Delivery Center
Given an N×M city grid where delivery centers are marked as 1 and houses as 0, find the minimum possible maximum Chebyshev distance (8-directional movement) from any house to its nearest delivery center by strategically placing at most one additional delivery center.
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
Early November, 2026
Early November, 2026
Late October, 2026
Amazon has multiple delivery centers all over the world. A city is given in the form of a grid where the delivery centers are marked as 1 and all other places are marked as 0. Distance between two cell is defined as the maximum absolute distance between x-coordinates and y-coordinates. For example, distance between (1, 2) and (0, 4) is max(|1-0|, |2-4|) = 2. The incovenience of the grid is defined as the maximum distance of any place marked 0 from its nearest delivery center. Amazon is planning to open a new delivery center to reduce the incovenience of the grid. Minimize the inconvenience of the grid by converting at most one 0(any place) to 1(a delivery center) and report this minimum value. Input 0 0 0 1 0 0 0 1 Distances to nearest delivery centeres 3 2 1 0 3 2 1 0 Initial incovenience is 3 Converting the (0, 0) to a delivery center 1 0 0 1 0 0 0 1 Now the inconvenience is 1 with distance as 0 1 1 0 1 1 1 0 Constraints n, m <= 500
Hello Interview Premium
Your account is free and you can post anonymously if you choose.