employer cover photo
employer logo

Question d’entretien chez VMware

Find a minimal editing distance between two strings

Réponse à la question d'entretien

Utilisateur anonyme

23 janv. 2017

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)