Lesson overview · Free interview practice

Palindromic Subsequence

Identify palindromic subsequences within strings.

Topics in the full lesson
  • Concept and Use Cases
  • When to Use
  • Time and Space Complexity
  • Common Problems
  • Longest Palindromic Subsequence
  • Minimum Deletions to Make a String Palindromic

Practice Problems

Work through a question before revealing its explanation. These questions and answers are free; Premium adds the full lesson walkthrough, examples and implementation detail.

Completion marks record your own progress, not an automatically checked result. The task type does not determine whether it is optional.

Question

Given a string s, find the longest subsequence that reads the same forwards and backwards (a palindrome). Return its length. A subsequence does not need to be contiguous.

Take a moment to think about this before revealing the answer

Explain your reasoning or try an implementation before comparing answers.

Question

Given a string s, return the number of palindromic substrings in it. Substrings of different lengths at different positions are counted separately, even if they consist of the same characters.

Take a moment to think about this before revealing the answer

Explain your reasoning or try an implementation before comparing answers.

Question

Given a string s, return the number of different non-empty palindromic subsequences of s. Two subsequences are different if there is some position i at which they have a different character. The answer can be very large; return it modulo 10^9 + 7.

Take a moment to think about this before revealing the answer

Explain your reasoning or try an implementation before comparing answers.

Explore the full Palindromic Subsequence material

Premium includes the complete lessons and implementation references. Free practice questions remain available without a subscription.

All course tracks & premium content
From basics to advanced masterclasses
Built for JS/TS developers like you
Real-world tips & common pitfalls
Upgrade to Premium