Skip to content

Commit 05861c8

Browse files
authored
fix: $79 boundary check (#398)
修改 if (board == null || word == null) return false; if (word.length() == 0) return true; if (board.length == 0) return false;
1 parent db0b917 commit 05861c8

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

problems/79.word-search.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,9 @@ _Java Code_
136136
```java
137137
public class LC79WordSearch {
138138
public boolean exist(char[][] board, String word) {
139-
if (board == null || board.length == 0 || board[0].length == 0
140-
|| word == null || word.length() == 0) return true;
139+
if (board == null || word == null) return false;
140+
if (word.length() == 0) return true;
141+
if (board.length == 0) return false;
141142
int rows = board.length;
142143
int cols = board[0].length;
143144
for (int r = 0; r < rows; r++) {

0 commit comments

Comments
 (0)