Hey guys can you help me convert this code into java... i started a little...
def minEditDistR(target, source):
""" Minimum edit distance. Straight from the recurrence. """
i = len(target); j = len(source)
if i == 0: return j
elif j == 0: return i
return(min(minEditDistR(target[:i-1],source)+1,
minEditDistR(target, source[:j-1])+1,
minEditDistR(target[:i-1], source[:j-1])+substCost(source[j-1], target[i-1])))
def substCost(x,y):
if x == y: return 0
else: return 2
Here is me trying
public static int distance (String s1, String s2){
int a = s1.length();
int b = s2.length();
if ( a == 0) return b;
if ( b == 0) return a;
Thank YOU!