FreeCareerPath
Build the PrimitiveMedium

Edit Distance

Write `min_distance(a, b)` returning the fewest single-character insertions, deletions or replacements that turn `a` into `b`. min_distance("horse", "ros") -> 3 On a match, carry the diagonal across for free. On a mismatch, take one plus the best of three neighbours — and be able to say which edit each one is: left is a deletion, above is an insertion, diagonal is a replacement. Interviewers ask exactly that.

What to expect: A timer starts when you begin. Edit the starter code, run it against the test suite as many times as you like, then finish when you're done. The reference solution and interviewer follow-up questions unlock only after you finish.

Log in to start this session

Timed sessions and your results for "Edit Distance" are saved to your account — logging in takes a few seconds.

Edit Distance — FreeCareerPath