Count Palindromic Subsequences

Given a string A,
find the total number of palindromic subsequences in A % 10^9+7.Palindromic subsequences need not to be distinct. You may assume that the maximum length of A is 1000.



Input Format

The only argument given is string A.

Output Format

find the total number of palindromic subsequences in A % 10^9+7.Palindromic subsequences need not to be distinct.

Constraints

1 <= length( A ) <= 1000

For Example

Example 1:

    Input 1 : 
    "babad"
    Output 1: 
    9
    All possible palindromic subsequences :- {"b", "a", "b", "a", "d", "bb", "aa", "bab", "aba"}

Example 2:

    Input 2:
    "cbbd"
    Output 2:
    5
    All possible palindromic subsequences :- {"c", "b", "b", "d", "bb"}
NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a doubt? Checkout Sample Codes for more details.
Start solving Count Palindromic Subsequences on Interview Code Editor
Sign Up
to access hints and editorial solutions for Count Palindromic Subsequences

Discussion


Loading...
Click here to start solving coding interview questions