@@ -69,10 +69,10 @@ private boolean solveHelper(int row, int col, char[][] board, HashSet<String> vi
69
69
}
70
70
71
71
// 分别尝试四个方向
72
- if (solveHelper(row - 1 , col, board, visited, memoization )
73
- || solveHelper(row, col - 1 , board, visited, memoization )
74
- || solveHelper(row + 1 , col, board, visited, memoization )
75
- || solveHelper(row, col + 1 , board, visited, memoization )) {
72
+ if (solveHelper(row - 1 , col, board, visited)
73
+ || solveHelper(row, col - 1 , board, visited)
74
+ || solveHelper(row + 1 , col, board, visited)
75
+ || solveHelper(row, col + 1 , board, visited)) {
76
76
return true ;
77
77
} else {
78
78
return false ;
@@ -167,7 +167,6 @@ public void solve(char[][] board) {
167
167
if (rows == 0 ) {
168
168
return ;
169
169
}
170
- HashSet<String > memoization = new HashSet<> ();
171
170
int cols = board[0 ]. length;
172
171
boolean [][] visited = new boolean [rows][cols];
173
172
for (int i = 0 ; i < cols; i++ ) {
@@ -230,7 +229,6 @@ public void solve(char[][] board) {
230
229
if (rows == 0 ) {
231
230
return ;
232
231
}
233
- HashSet<String > memoization = new HashSet<> ();
234
232
int cols = board[0 ]. length;
235
233
for (int i = 0 ; i < cols; i++ ) {
236
234
// 最上边一行的所有 O 做 DFS
0 commit comments