Coding
Find the shortest distance from all buildings to an empty land in a grid.
You are given a grid of values 0, 1, or 2, where 0 is empty land, 1 is a building, and 2 is an obstacle. Find the shortest travel distance from all buildings to an empty land spot.
Input: grid = [[1,0],[0,1]]
Output: 2
Explanation: The empty lands are at (0,1) and (1,0). Both empty lands are exactly 1 step away from each building. Total distance = 1 + 1 = 2.
Was asked at