Pregunta de entrevista de Meta

Find if one string is "oneEditAway" from another string

Respuestas de entrevistas

Anónimo

15 de nov de 2014

Is replacement one of options? If so, I think previous answer would be perfect if we add one more check oneEditAway(string1.substring(i+1), string2.substring(i+1))

1

Anónimo

1 de dic de 2014

not really agree with the answer. how about this: bool OneEdit(string a, string b) { if (abs(int(a.size()-b.size()))>1) return false; int i=0; for (;ib.size()) return a.substr(i+1)==b.substr(i); else if (a.size()

2

Anónimo

27 de oct de 2014

You can solve it via the regular method. Check if there is a character mismatch and if there is then go ahead in the loop and if another mismatch is found you return false. You have to consider some edge cases such as different length of strings. Easier way to do it is : Psuedocode boolean oneEditAway(String string1,String string2) for(int i =0;i

1