Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 03bcdeb

Browse files
committedSep 1, 2024·
Word Search
visit object create only once
1 parent ce5152f commit 03bcdeb

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed
 

‎word-search/TonyKim9401.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@
77
class Solution {
88
public boolean exist(char[][] board, String word) {
99
// Mark visited path to do not go back.
10-
boolean[][] visit;
10+
boolean[][] visit = new boolean[board.length][board[0].length];
1111

1212
for (int i = 0; i < board.length; i++) {
1313
for (int j = 0; j < board[0].length; j++) {
14-
visit = new boolean[board.length][board[0].length];
1514
if (wordSearch(i, j, 0, word, board, visit)) return true;
1615
}
1716
}

0 commit comments

Comments
 (0)
Please sign in to comment.