def getMinInconvenience(grid: list[list[int]]) -> int:
The round: the coding half of Amazon's online assessment; the other half is an AI-assisted task in a code repository, usually debugging. Seven candidates reported this grid question between June and September 2026, five of them in August or September, and a round-up of June–September Amazon reports says several August OAs had it. Three candidates posted the prompt; two give the constraints, and one gives the function name and a second example. The examples and constraints below are as reported; the prose is paraphrased.
Problem
You are given an n × m grid where 1 is a delivery center and 0 is an empty location. The distance between cells (r1, c1) and (r2, c2) is the Chebyshev distance max(|r1 - r2|, |c1 - c2|). The grid's inconvenience is the largest distance from any 0 cell to its nearest delivery center. You may convert at most one 0 into a 1. Return the minimum possible inconvenience.
def getMinInconvenience(grid: list[list[int]]) -> int: ...
Constraints
1 ≤ n, m ≤ 500grid[i][j] is 0 or 1Example 1
grid = [[0, 0, 0, 1],
[0, 0, 0, 1]]
Distances now: 3 2 1 0 / 3 2 1 0 -> inconvenience 3
Convert (0, 0): 0 1 1 0 / 1 1 1 0 -> inconvenience 1
Output: 1
Example 2
grid = [[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0]]
Convert (1, 1); every cell is then within distance 2.
Output: 2
Reported variant: 4-direction distance. In one thread the worked example uses Manhattan distance, |r1 - r2| + |c1 - c2| (moves only up, down, left and right): [[0, 0, 0, 0], [0, 0, 0, 1]] has inconvenience 4, and converting the top-left cell brings it to 2. A reply there likens it to LeetCode 542 (01 Matrix) with one flip added and says five tests timed out. Ask which distance applies; the two give different answers on most grids. The last two tests call the variant as getMinInconvenienceManhattan(grid), same input and output.
def getMinInconvenienceManhattan(grid: list[list[int]]) -> int: ...
Candidates call it hard. Replies on one report say that as a live interview almost nobody would solve it, especially in 40 minutes without having seen it before; a reply on another says even solving it does not guarantee passing the OA. Three candidates describe a BFS for the current distances followed by a binary search on the answer; one of them checks each K by bounding the cells still too far away. The candidate in the 4-direction thread got stuck and did not write a solution; a reply there says five tests timed out.
Also reported as getMinInconvenience
The round: the coding half of Amazon's online assessment; the other half is an AI-assisted task in a code repository, usually debugging. Seven candidates reported this grid question between June and September 2026, five of them in August or September, and a round-up of June–September Amazon reports says several August OAs had it. Three candidates posted the prompt; two give the constraints, and one gives the function name and a second example. The examples and constraints below are as reported; the prose is paraphrased.
Problem
You are given an n × m grid where 1 is a delivery center and 0 is an empty location. The distance between cells (r1, c1) and (r2, c2) is the Chebyshev distance max(|r1 - r2|, |c1 - c2|). The grid's inconvenience is the largest distance from any 0 cell to its nearest delivery center. You may convert at most one 0 into a 1. Return the minimum possible inconvenience.
def getMinInconvenience(grid: list[list[int]]) -> int: ...
Constraints
1 ≤ n, m ≤ 500grid[i][j] is 0 or 1Example 1
grid = [[0, 0, 0, 1],
[0, 0, 0, 1]]
Distances now: 3 2 1 0 / 3 2 1 0 -> inconvenience 3
Convert (0, 0): 0 1 1 0 / 1 1 1 0 -> inconvenience 1
Output: 1
Example 2
grid = [[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0]]
Convert (1, 1); every cell is then within distance 2.
Output: 2
Reported variant: 4-direction distance. In one thread the worked example uses Manhattan distance, |r1 - r2| + |c1 - c2| (moves only up, down, left and right): [[0, 0, 0, 0], [0, 0, 0, 1]] has inconvenience 4, and converting the top-left cell brings it to 2. A reply there likens it to LeetCode 542 (01 Matrix) with one flip added and says five tests timed out. Ask which distance applies; the two give different answers on most grids. The last two tests call the variant as getMinInconvenienceManhattan(grid), same input and output.
def getMinInconvenienceManhattan(grid: list[list[int]]) -> int: ...
What candidates report: Three candidates posted the prompt with Chebyshev distance and a fourth describes 8-direction moves, which is the same thing; in one thread the worked example uses 4-direction (Manhattan) distance instead.; Three candidates describe a multi-source BFS for the current distances followed by a binary search on the answer; one of them checks each K by bounding the cells that are still too far.; Replies on one report say almost nobody would solve it in 40 minutes without having seen it.
Our note (not from the reports): The squares overlap exactly when the far cells' bounding box spans at most 2K rows and 2K columns. Ask which distance applies before coding.
Send them this page. It is free to read, no account needed.
What you just read — canonical solution, follow-up arc, what passing candidates actually did — exists for all 57 Amazon questions, refreshed monthly from new candidate reports.