SubPalindrome

3.6

37 votes
Problem

For every string given as input, you need to tell us the number of subsequences of it that are palindromes (need not necessarily be distinct). Note that the empty string is not a palindrome.

Sample Input
1
aab
Sample Output
4
Time Limit: 5
Memory Limit: 256
Source Limit:
Explanation

the palindromic subsequences of "aab" are: "a", "a", "b", "aa", and the method returns 4.

Contributers:
Editor Image

?