Data Structures & AlgorithmsVery hardICPC regional · Product Company SDE

Problem: What is the length of the longest common subsequence of the three strings "abc", "abd" and "ab"?

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

Correct answer: C. 2

The three-string LCS extends the two-string table by one dimension. Taking the pairwise LCS minimum would be a shortcut that does not give the common subsequence of all three.

More Coding Interview Problems questions

Exams that ask this topic