Data Structures & AlgorithmsHardGATE CS

Find the length of the longest common subsequence of X = "AGGTABQXZRYWM" and Y = "GXTXAYBZQMWRY".

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

Correct answer: A. 7

Standard LCS dynamic programming gives 7. The longest common substring is only 2, so confusing subsequence with substring undershoots badly.

More Coding Interview Problems questions

Exams that ask this topic