Data Structures & AlgorithmsHardTCS NQT · Infosys coding round

Problem: Using insert, delete and replace, each costing 1, what is the minimum number of operations to convert "dragon" into "lantern"?

  1. A. 9
  2. B. 1
  3. C. 7
  4. D. 6

Correct answer: D. 6

The Levenshtein DP gives 6 for dragon → lantern. Allowing only inserts and deletes gives m + n − 2·LCS = 9, counting position-by-position mismatches plus the length difference gives 7, and the length difference alone is 1.

More Coding Interview Problems questions

Exams that ask this topic