โ† Amazon questions

As Far from Land as Possible

Filed under Amazon

Given an N x N grid containing only 0s (water) and 1s (land), find a 0 cell such that the distance to the nearest 1 is maximized. Return the maximum distance. If no 0 or no 1 exists, return -1.

You've read your 3 free write-ups

Sign up free to keep reading. Your account opens the first 10 questions of every company.

Related Amazon questions

Collected from public candidate posts and coding forums. Updated Nov 2026.