Data Structures & AlgorithmsHardProduct Company SDE · Amazon OA

Problem: The edit distance (insert, delete, replace, each cost 1) between "horse" and "ros" is computed. What is it?

  1. A. 4
  2. B. 3
  3. C. 2
  4. D. 5

Correct answer: B. 3

Levenshtein distance via the standard table: remove 'h', replace 'r' is kept, and remove 'e' gives three operations in total. Counting only the length difference gives 2, which is too small.

More Coding Interview Problems questions

Exams that ask this topic