mirror of
https://github.com/krahets/hello-algo.git
synced 2026-04-03 02:30:25 +08:00
Fix a definition.
This commit is contained in:
@@ -75,7 +75,7 @@ def edit_distance_dp(s: str, t: str) -> int:
|
||||
|
||||
|
||||
def edit_distance_dp_comp(s: str, t: str) -> int:
|
||||
"""编辑距离:状态压缩后的动态规划"""
|
||||
"""编辑距离:空间优化后的动态规划"""
|
||||
n, m = len(s), len(t)
|
||||
dp = [0] * (m + 1)
|
||||
# 状态转移:首行
|
||||
@@ -118,6 +118,6 @@ if __name__ == "__main__":
|
||||
res = edit_distance_dp(s, t)
|
||||
print(f"将 {s} 更改为 {t} 最少需要编辑 {res} 步")
|
||||
|
||||
# 状态压缩后的动态规划
|
||||
# 空间优化后的动态规划
|
||||
res = edit_distance_dp_comp(s, t)
|
||||
print(f"将 {s} 更改为 {t} 最少需要编辑 {res} 步")
|
||||
|
||||
Reference in New Issue
Block a user