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?
- A. 4
- B. 3
- C. 2
- 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
- Problem: What is the length of the longest common subsequence of the three strings "abc", "abd" and "ab"?
- Problem: Split the array [7, 2, 5, 10, 8] into 2 contiguous non-empty parts so that the largest part sum is as small as possible. What is…
- Problem: A 3×3 spiral is filled starting with 1 at the top-left and moving right, then down, then left, then up, spiralling inward. What…
- Problem: Count the unordered pairs (x, y) with 1 ≤ x < y ≤ 7 for which x OR y equals 7.
- Problem: In base 8, how many trailing zeros does 100! have?
- Problem: What is the sum of the divisors of 360 that are perfect squares?