Distinct palindromic substrings
Hard Accuracy: 71.39% Submissions: 3167 Points: 8

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(N2logN)
Expected Auxilliary Space : O(N2)

Constraints:
1 ≤ N ≤ 2*103, where N is the length of the string str.

We are replacing the old Disqus forum with the new Discussions section given below.
Click here to view old Disqus comments.


to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes

All Submissions

My Submissions:

Login to access your submissions.

Distinct palindromic substrings

Output Window