diff --git a/python/072_Edit_Distance.py b/python/072_Edit_Distance.py index e9033cc..f0cdc13 100644 --- a/python/072_Edit_Distance.py +++ b/python/072_Edit_Distance.py @@ -24,7 +24,7 @@ class Solution(object): def minDistance(self, word1, word2): ls_1, ls_2 = len(word1), len(word2) - dp = range(ls_1 + 1) + dp = list(range(ls_1 + 1)) for j in range(1, ls_2 + 1): pre = dp[0] dp[0] = j @@ -36,3 +36,10 @@ def minDistance(self, word1, word2): dp[i] = min(pre + 1, dp[i] + 1, dp[i - 1] + 1) pre = temp return dp[ls_1] + + +if __name__ == '__main__': + # begin + s = Solution() + print (s.minDistance("horse","ros")) + print (s.minDistance("intention","execution")) diff --git a/python/078_Subsets.py b/python/078_Subsets.py index 9e3dfc0..8738707 100644 --- a/python/078_Subsets.py +++ b/python/078_Subsets.py @@ -55,4 +55,4 @@ def subsets(self, nums): if __name__ == "__main__": s = Solution() - print s.subsets([1,2,3]) + print (s.subsets([1,2,3]))