Data Structures & AlgorithmsModerateCodeforces Div2 B-D · ICPC regional

Keeping only a palindrome (as a subsequence) of "abcba" needs no deletion at all, since the string is a palindrome already. What is the length of its longest palindromic subsequence?

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

Correct answer: A. 5

The whole string is a palindrome, so the longest palindromic subsequence has full length 5. Interval DP reaches the same value.

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

Exams that ask this topic