Skip to content

Commit 4db1d3f

Browse files
committed
refactor: remove redundant code
移除冗余代码
1 parent 41032c9 commit 4db1d3f

File tree

3 files changed

+0
-10
lines changed

3 files changed

+0
-10
lines changed

lcof/面试题12. 矩阵中的路径/README.md

-5
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ class Solution:
4242
visited = [[False for _ in range(cols)] for _ in range(rows)]
4343
for i in range(rows):
4444
for j in range(cols):
45-
if board[i][j] != word[0]:
46-
continue
4745
if self.visit(board, visited, i, j, rows, cols, word):
4846
return True
4947
return False
@@ -70,9 +68,6 @@ class Solution {
7068
boolean[][] visited = new boolean[rows][cols];
7169
for (int i = 0; i < rows; ++i) {
7270
for (int j = 0; j < cols; ++j) {
73-
if (board[i][j] != word.charAt(0)) {
74-
continue;
75-
}
7671
if (visit(board, visited, i, j, rows, cols, word)) {
7772
return true;
7873
}

lcof/面试题12. 矩阵中的路径/Solution.java

-3
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@ public boolean exist(char[][] board, String word) {
77
boolean[][] visited = new boolean[rows][cols];
88
for (int i = 0; i < rows; ++i) {
99
for (int j = 0; j < cols; ++j) {
10-
if (board[i][j] != word.charAt(0)) {
11-
continue;
12-
}
1310
if (visit(board, visited, i, j, rows, cols, word)) {
1411
return true;
1512
}

lcof/面试题12. 矩阵中的路径/Solution.py

-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ def exist(self, board: List[List[str]], word: str) -> bool:
66
visited = [[False for _ in range(cols)] for _ in range(rows)]
77
for i in range(rows):
88
for j in range(cols):
9-
if board[i][j] != word[0]:
10-
continue
119
if self.visit(board, visited, i, j, rows, cols, word):
1210
return True
1311
return False

0 commit comments

Comments
 (0)