Data Structures & AlgorithmsModerateICPC regional · Amazon SDE OA

What is the length of the longest common substring (contiguous) of "abcdef" and "zcdemf"?

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

Correct answer: C. 3

The common contiguous block is "cde" of length 3. The longest common subsequence ("cdef" of length 4 is not contiguous in both) is a different quantity.

More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions

Exams that ask this topic