Skip to content

Commit fa2b504

Browse files
Upgrade 072_Edit_Distance.py to python 3 (qiyuangong#28)
* Upgrade 072_Edit_Distance.py to python 3, by @peterhuang1kimo
1 parent 82b3bb7 commit fa2b504

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

python/072_Edit_Distance.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class Solution(object):
2424

2525
def minDistance(self, word1, word2):
2626
ls_1, ls_2 = len(word1), len(word2)
27-
dp = range(ls_1 + 1)
27+
dp = list(range(ls_1 + 1))
2828
for j in range(1, ls_2 + 1):
2929
pre = dp[0]
3030
dp[0] = j
@@ -36,3 +36,10 @@ def minDistance(self, word1, word2):
3636
dp[i] = min(pre + 1, dp[i] + 1, dp[i - 1] + 1)
3737
pre = temp
3838
return dp[ls_1]
39+
40+
41+
if __name__ == '__main__':
42+
# begin
43+
s = Solution()
44+
print (s.minDistance("horse","ros"))
45+
print (s.minDistance("intention","execution"))

0 commit comments

Comments
 (0)