Search⌘ K
AI Features

Solution: Count Palindromic Subsequences

Let's solve the Count Palindromic Subsequences problem using the Dynamic Programming pattern.

Statement

Given a string s made up only of digit characters, count how many subsequences of s form a palindrome of length 55.

Return the total number of such palindromic subsequences.

Note:

  • A string is palindromic if it reads the same forward and backward.

  • A subsequence is obtained by deleting zero or more characters from s without changing the relative order of the remaining characters.

  • A subsequence is defined by the indices chosen from s, so identical resulting strings formed from different index selections are counted multiple times.

Constraints:

  • 11 \leq ...