Data Structures & AlgorithmsModerateGATE CS · TCS NQT
What is the length of the longest palindromic subsequence of the string leetcode?
- A. 4
- B. 2
- C. 5
- 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.
Practise more Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questionsArrays, Strings, Linked Lists, Stacks, Queues and Hashing: notes and key points
More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions
- How many contiguous non-empty substrings of aaabbbaa consist of a single repeated letter?
- What is the sum of the distinct prime divisors of 2310?
- How many positive divisors does 2^5 3^3 5^2 have?
- How many integers x in [1, 200] are divisible by 4 but not by 6?
- What is the sum of (x^2 mod 13) for x = 1 to 12, taken modulo 13?
- How many ordered pairs (a, b) with 1 <= a, b <= 10 satisfy (a + b) mod 5 = 0?