Why am I getting runtime error NZEC with this code? Runs perfectly with the sample input too on my IDE.
def editDistance(str1, str2, m, n):
if m == 0:
return n
if n == 0:
return m
if str1[m-1] == str2[n-1]:
return editDistance(str1, str2, m-1, n-1)
return 1 + min(editDistance(str1, str2, m, n-1), # Insert
editDistance(str1, str2, m-1, n), # Remove
editDistance(str1, str2, m-1, n-1) # Replace
)
# Driver code
t = int(input())
while t:
t = t-1
str1 = input()
str2 = input()
print(editDistance(str1, str2, len(str1), len(str2)))
print("")