Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitfd46b03

Browse files
fix build
1 parent04a0f72 commitfd46b03

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 (inti =0;i <row;i++) {
5353
for (intj =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
returntrue;
56+
}
5657
}
5758
}
5859
returnfalse;
5960
}
6061

6162
privatebooleansearch(char[][]board,inti,intj,Stringword,intindex) {
62-
if (index ==word.length() -1)
63+
if (index ==word.length() -1) {
6364
returntrue;
65+
}
6466

6567
// store the visited char in temp variable
6668
chartemp =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
returntrue;
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
returntrue;
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
returntrue;
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
returntrue;
83+
}
7984

8085
board[i][j] =temp;
8186
returnfalse;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp