Skip to content

Commit fd46b03

Browse files
fix build
1 parent 04a0f72 commit fd46b03

File tree

1 file changed

+12
-7
lines changed
  • src/main/java/com/fishercoder/solutions

1 file changed

+12
-7
lines changed

src/main/java/com/fishercoder/solutions/_79.java

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,31 +51,36 @@ public boolean exist(char[][] board, String word) {
5151

5252
for (int i = 0; i < row; i++) {
5353
for (int j = 0; j < col; j++) {
54-
if (board[i][j] == word.charAt(0) && search(board, i, j, word, 0) == true)
54+
if (board[i][j] == word.charAt(0) && search(board, i, j, word, 0) == true) {
5555
return true;
56+
}
5657
}
5758
}
5859
return false;
5960
}
6061

6162
private boolean search(char[][] board, int i, int j, String word, int index) {
62-
if (index == word.length() - 1)
63+
if (index == word.length() - 1) {
6364
return true;
65+
}
6466

6567
// store the visited char in temp variable
6668
char temp = board[i][j];
6769
board[i][j] = ' ';
68-
if (i > 0 && board[i - 1][j] == word.charAt(index + 1) && search(board, i - 1, j, word, index + 1) == true)
70+
if (i > 0 && board[i - 1][j] == word.charAt(index + 1) && search(board, i - 1, j, word, index + 1) == true) {
6971
return true;
70-
if (i < board.length - 1 && board[i + 1][j] == word.charAt(index + 1) && search(board, i + 1, j, word, index + 1) == true)
72+
}
73+
if (i < board.length - 1 && board[i + 1][j] == word.charAt(index + 1) && search(board, i + 1, j, word, index + 1) == true) {
7174
return true;
75+
}
7276

73-
if (j > 0 && board[i][j - 1] == word.charAt(index + 1) && search(board, i, j - 1, word, index + 1) == true)
77+
if (j > 0 && board[i][j - 1] == word.charAt(index + 1) && search(board, i, j - 1, word, index + 1) == true) {
7478
return true;
79+
}
7580

76-
77-
if (j < board[0].length - 1 && board[i][j + 1] == word.charAt(index + 1) && search(board, i, j + 1, word, index + 1) == true)
81+
if (j < board[0].length - 1 && board[i][j + 1] == word.charAt(index + 1) && search(board, i, j + 1, word, index + 1) == true) {
7882
return true;
83+
}
7984

8085
board[i][j] = temp;
8186
return false;

0 commit comments

Comments
 (0)