Your Dashboard
Interview Coaching
Learn
System Design
ML System Design
Code
Behavioral
Salary Negotiation
Interview Guides
Leetcode 317. Shortest Distance from All Buildings
Given a grid with buildings (1), empty land (0), and obstacles (2), find an empty cell that minimizes the sum of shortest (Manhattan) path distances from all buildings while avoiding obstacles; return that minimum sum or -1 if no empty cell is reachable from every building. This problem primarily requires repeated BFS distance accumulation and reachability checks from each building to identify the globally optimal empty location.
Asked at:
Doordash
Meta
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
Early September, 2025
Meta
Senior
Mid June, 2025
Meta
Senior
Mid February, 2025
Doordash
Mid-level
Comments
Hello Interview Premium
Your account is free and you can post anonymously if you choose.