Back to QuestionsPractice with This Question
Shortest Distance from All Buildings (BFS)
133.3K views•Asked at Meta•
Hard
Question Explain
You are given a grid of 0s, 1s, and 2s. Find an empty land (0) that has the shortest total travel distance to all buildings (1s). This is a multi-source shortest path problem using BFS.
Start Trying This Question Simulation
Practice answering orally or with text to get instant AI feedback.