Data Structures & AlgorithmsModerateGATE CS · ICPC regional

What is the length of the longest palindromic subsequence of the string agbdba?

  1. A. 6
  2. B. {C-1}
  3. C. 5
  4. D. 7

Correct answer: C. 5

The subsequence abdba uses letters that are not contiguous in agbdba; the DP takes the best of matching or skipping an end character.

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

Exams that ask this topic