Data Structures & AlgorithmsHardProduct-company placement

For the string ABRACADABRA, what are the lengths of the longest palindromic SUBSTRING and the longest palindromic SUBSEQUENCE?

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

Correct answer: C. 3 and 7

The substring must be contiguous (expand around centres: 3); the subsequence may skip letters and equals LCS(s, reverse(s)) = 7.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic