Skip to content

Commit 406abff

Browse files
refactor(algorithms, backtracking, dfs trie): check for empty grid
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent 5fb290f commit 406abff

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

algorithms/backtracking/word_search/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ def find_strings(grid: List[List[str]], words: List[str]) -> List[str]:
8181
for word in words:
8282
trie.insert(word)
8383

84+
if not grid or not grid[0]:
85+
return []
86+
8487
rows_count, cols_count = len(grid), len(grid[0])
8588
result = []
8689

0 commit comments

Comments
 (0)