Minimize Maximum Distance by Adding One Colored Source

Asked at Amazon · Coding Questions · Difficulty: Hard

Given an `n x m` grid with `k` initially colored cells, choose **exactly one** additional cell to become a new colored source. Movement is 8-directional with unit cost, so a cell's inconvenience is its Chebyshev distance to the nearest colored source (initial or new). Return the minimum possible value of the maximum inconvenience over all cells after adding one source optimally. Sources are given 1-indexed; `n*m <= 2e5`.

Loading the problem…