Skip to content

Commit 92b9ed0

Browse files
committed
refactor(algorithms, graphs): empty grid check
1 parent 5916082 commit 92b9ed0

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

algorithms/graphs/min_cost_valid_path/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,8 @@ def is_valid_and_improvable(row, col) -> bool:
204204

205205

206206
def min_cost_dfs_and_bfs(grid: List[List[int]]) -> int:
207+
if not grid:
208+
return 0
207209
# Direction vectors: right, left, down, up (matching grid values 1,2,3,4)
208210
dirs = [(0, 1), (0, -1), (1, 0), (-1, 0)]
209211
num_rows = len(grid)

0 commit comments

Comments
 (0)