โ† Amazon questions

Optimal position for house

Filed under Amazon

Given an M x N matrix of 0s (empty) and 1s (offices), find the coordinates (r, c) of an empty cell (0) that minimizes the sum of Manhattan distances to all offices (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.