Skip to content

Commit 7e6404d

Browse files
authored
fix: $79 boundary check (#397)
1 parent 05861c8 commit 7e6404d

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

problems/79.word-search-en.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,9 @@ Found match with word, return `True`.
120120
```java
121121
public class LC79WordSearch {
122122
public boolean exist(char[][] board, String word) {
123-
if (board == null || board.length == 0 || board[0].length == 0
124-
|| word == null || word.length() == 0) return true;
123+
if (board == null || word == null) return false;
124+
if (word.length() == 0) return true;
125+
if (board.length == 0) return false;
125126
int rows = board.length;
126127
int cols = board[0].length;
127128
for (int r = 0; r < rows; r++) {
@@ -239,4 +240,4 @@ var exist = function(board, word) {
239240
```
240241

241242
## References
242-
1. [Backtracking Wiki](https://www.wikiwand.com/en/Backtracking)
243+
1. [Backtracking Wiki](https://www.wikiwand.com/en/Backtracking)

0 commit comments

Comments
 (0)