Data Structures & AlgorithmsHardProduct-company MCQ pattern

What is the length of the longest palindromic SUBSEQUENCE of CHARACTER?

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

Correct answer: C. 5

C A R A C (positions 1, 3, 4, 5, 6 of CHARACTER) is a palindrome of length 5, and the DP gives no longer one. 3 is the longest palindromic SUBSTRING (ARA); a subsequence need not be contiguous.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic