← Microsoft questions

Count cells with zero based on Manhattan distance to ones

Filed under Microsoft

Given a 2D binary array of size N*M and an integer K, find the total number of cells with value 0 such that the Manhattan distance from every cell with value 1 to it is not more than K units.

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 Microsoft questions

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