VMware Interview Question: Find a minimal editing distan... | Glassdoor

Interview Question

Software Engineer Interview Palo Alto, CA

Find a minimal editing distance between two strings

Answer

Interview Answer

1 Answer

0

x = "Ravi is a Ravi student at SJSU. Ravi is a male. Ravi is an engineer."
# Given String

y = x.split(" ")
#print y
c = []
for i in range(len(y)):
    if y[i] == "Ravi":
        c.append(i)
#print c
s = []
for i in range(1,len(c)):
    temp = c[i] - c[i-1]

    for j in range(c[i-1]+1, c[i]):
      # print y[j]
       temp1 = len(y[j])
       #print temp1
       temp+=temp1
       #print temp1
    s.append(temp)
print min(s)

Raviteja Ainampudi on Jan 23, 2017

Add Answers or Comments

To comment on this, Sign In or Sign Up.