Skip to content

Practice Count Palindromic Subsequences

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Hard#2484
LeetCode Problem

Count Palindromic Subsequences

Problem Statement

Given a string of digits s, return the number of palindromic subsequences of s having length 5. Since the answer may be very large, return it modulo 10^9 + 7.

Source: Count Palindromic Subsequences on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
s = "103301"
Output
2

# Example 2

Input
s = "0000000"
Output
21

# Example 3

Input
s = "9999900000"
Output
2

Constraints

1 <= s.length <= 10^4
s consists of digits.

Related LeetCode Problems

Practice more problems similar to Count Palindromic Subsequences.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.