Data Structures & AlgorithmsHardGATE CS

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

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

Correct answer: A. 1 and 3

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

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic