refactor: remove Java code sections from all LeetCode Hot 100 markdown files
- Remove all "## Java 解法" sections and Java code blocks - Replace "## Go 解法" with "## 解法" - Remove "### Go 代码要点" and "### Java 代码要点" sections - Keep all Go code sections intact - Maintain complete documentation structure and content - Update 22 markdown files in the LeetCode Hot 100 directory
This commit is contained in:
@@ -97,49 +97,6 @@ func exist(board [][]byte, word string) bool {
|
||||
|
||||
### Java 实现
|
||||
|
||||
```java
|
||||
public class Solution {
|
||||
private boolean[][] visited;
|
||||
private int[][] directions = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
|
||||
|
||||
public boolean exist(char[][] board, String word) {
|
||||
int m = board.length, n = board[0].length;
|
||||
visited = new boolean[m][n];
|
||||
|
||||
for (int i = 0; i < m; i++) {
|
||||
for (int j = 0; j < n; j++) {
|
||||
if (board[i][j] == word.charAt(0) && dfs(board, word, i, j, 0)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean dfs(char[][] board, String word, int i, int j, int k) {
|
||||
if (k == word.length()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (i < 0 || i >= board.length || j < 0 || j >= board[0].length ||
|
||||
visited[i][j] || board[i][j] != word.charAt(k)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
visited[i][j] = true;
|
||||
|
||||
for (int[] dir : directions) {
|
||||
if (dfs(board, word, i + dir[0], j + dir[1], k + 1)) {
|
||||
visited[i][j] = false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
visited[i][j] = false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 复杂度分析
|
||||
|
||||
|
||||
Reference in New Issue
Block a user