Data Structures & AlgorithmsModerateGATE CS · TCS NQT

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

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

Correct answer: D. 3

The longest palindromic subsequence has length 3, for example eee (positions 1, 2, 7) or ece. No palindrome of length 4 exists, which the DP confirms.

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

Exams that ask this topic