P21699 [GeeksforGeeks] Distinct palindromic substrings5141
提高-
题目描述

Given a string str of lowercase ASCII characters, Count the number of distinct continuous palindromic sub-strings which are present in the string str.
Example 1:
Input:
str = "abaaa"
Output:
5
Explanation : These are included in answer:
"a","aa","aaa","aba","b"
Example 2:
Input
str = "geek"
Output:
4
Explanation : Below are 4 palindrome sub-strings
"e","ee","g","k"
Your Task:
You don't need to read input or print anything. Your task is to complete the function palindromeSubStrs() which takes the string str as input parameter and returns the total number of distinct continuous palindromic sub-strings in str.
Expected Time Complexity : O(N^{2}logN)
Expected Auxilliary Space : O(N^{2})
Constraints:
1 ≤ N ≤ 3*10^{3}, where N is the length of the string str.

输入格式

见题面

输出格式

见题面

样例输入
str = "abaaa"
样例输出
5