Question d’entretien chez Meta

Find if one string is "oneEditAway" from another string

Réponses aux questions d'entretien

Utilisateur anonyme

15 nov. 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

Utilisateur anonyme

1 déc. 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

Utilisateur anonyme

27 oct. 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