Skip to content

Commit 48714db

Browse files
author
lucifer
committed
2 parents a332f84 + 7e6404d commit 48714db

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
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)

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)