Skip to content

Commit

Permalink
Update 15. Shortest Distance from All Buildings.py
Browse files Browse the repository at this point in the history
  • Loading branch information
SamirPaulb authored Mar 2, 2024
1 parent b833ebb commit 8248532
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions 07_Graph/15. Shortest Distance from All Buildings.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,8 @@ def shortest_distance(self, grid):

# If no cell can reach all buildings, return -1; otherwise, return the minimum distance
return -1 if answer == float('inf') else answer



# Time: O((m * n) * (m * n)) # where m is the number of rows and n is the number of columns in the grid. As there could be up to m * n buildings in the worst case.
# Space: O(m * n)

0 comments on commit 8248532

Please sign in to comment.