Geeksforgeeks

Error

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 ≤ 2*10^{3}, 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.

Click here to view old Disqus comments.

Login to report an issue on this page.

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

YesLoading...

Distinct palindromic substrings

...