Skip to content

Commit ee84382

Browse files
asdf2014actions-user
authored andcommitted
Code Formatter & Update Leaderboard
1 parent cc6473c commit ee84382

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

Codes/gracekoo/interview_65.py

+13-3
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,27 @@ class Solution:
1010
def exist(self, board: List[List[str]], word: str) -> bool:
1111
def dfs(i, j, k):
1212
# 递归异常退出的条件:索引超出范围或者与当前字母不匹配
13-
if not 0 <= i < len(board) or not 0 <= j < len(board[0]) or word[k] != board[i][j] or board[i][j] == "*":
13+
if (
14+
not 0 <= i < len(board)
15+
or not 0 <= j < len(board[0])
16+
or word[k] != board[i][j]
17+
or board[i][j] == "*"
18+
):
1419
return False
1520
# 递归成功退出的条件
16-
if k == len(word)-1:
21+
if k == len(word) - 1:
1722
return True
1823

1924
# 继续向上下左右进行遍历
2025
tmp = board[i][j]
2126
board[i][j] = "*" # *表示已经遍历过
2227

23-
result = dfs(i-1, j, k+1) or dfs(i+1, j, k+1) or dfs(i, j-1, k+1) or dfs(i, j+1, k+1)
28+
result = (
29+
dfs(i - 1, j, k + 1)
30+
or dfs(i + 1, j, k + 1)
31+
or dfs(i, j - 1, k + 1)
32+
or dfs(i, j + 1, k + 1)
33+
)
2434

2535
board[i][j] = tmp # 不管遍历结果如何,都需要恢复相应字符
2636
return result

README-en.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ bash -c "$(curl -L https://raw.githubusercontent.com/asdf2014/algorithm/master/f
6666

6767
| User | Latest Active Date |
6868
| :--: | :----------------: |
69-
| **[gracekoo](https://github.com/asdf2014/algorithm/tree/master/Codes/gracekoo)** | 2020-10-14 07:32:31 |
69+
| **[gracekoo](https://github.com/asdf2014/algorithm/tree/master/Codes/gracekoo)** | 2020-10-14 09:14:27 |
7070
| **[liuliangju](https://github.com/asdf2014/algorithm/tree/master/Codes/liuliangju)** | 2020-09-30 07:12:07 |
7171
| **[ZZhang](https://github.com/asdf2014/algorithm/tree/master/Codes/ZZhang)** | 2020-09-09 19:46:14 |
7272
| [zsdostar](https://github.com/asdf2014/algorithm/tree/master/Codes/zsdostar) | 2020-09-06 20:28:37 |

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ bash -c "$(curl -L https://raw.githubusercontent.com/asdf2014/algorithm/master/f
7171

7272
| User | Latest Active Date |
7373
| :--: | :----------------: |
74-
| **[gracekoo](https://github.com/asdf2014/algorithm/tree/master/Codes/gracekoo)** | 2020-10-14 15:32:31 |
74+
| **[gracekoo](https://github.com/asdf2014/algorithm/tree/master/Codes/gracekoo)** | 2020-10-14 17:14:27 |
7575
| **[liuliangju](https://github.com/asdf2014/algorithm/tree/master/Codes/liuliangju)** | 2020-09-30 15:12:07 |
7676
| **[ZZhang](https://github.com/asdf2014/algorithm/tree/master/Codes/ZZhang)** | 2020-09-10 03:46:14 |
7777
| [zsdostar](https://github.com/asdf2014/algorithm/tree/master/Codes/zsdostar) | 2020-09-07 04:28:37 |

0 commit comments

Comments
 (0)