@@ -69,10 +69,10 @@ private boolean solveHelper(int row, int col, char[][] board, HashSet<String> vi
6969 }
7070
7171 // 分别尝试四个方向
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)) {
7676 return true ;
7777 } else {
7878 return false ;
@@ -167,7 +167,6 @@ public void solve(char[][] board) {
167167 if (rows == 0 ) {
168168 return ;
169169 }
170- HashSet<String > memoization = new HashSet<> ();
171170 int cols = board[0 ]. length;
172171 boolean [][] visited = new boolean [rows][cols];
173172 for (int i = 0 ; i < cols; i++ ) {
@@ -230,7 +229,6 @@ public void solve(char[][] board) {
230229 if (rows == 0 ) {
231230 return ;
232231 }
233- HashSet<String > memoization = new HashSet<> ();
234232 int cols = board[0 ]. length;
235233 for (int i = 0 ; i < cols; i++ ) {
236234 // 最上边一行的所有 O 做 DFS
0 commit comments