Count Palindrome Sub-Strings of a String
Medium Accuracy: 52.66% Submissions: 3878 Points: 4

Given a string, the task is to count all palindromic sub-strings present in it. Length of palindrome sub-string must be greater than or equal to 2. 

Example

Input
N = 5
str = "abaab"
Output
3
Explanation:
All palindrome substring are : "aba" , "aa" , "baab"

Example

Input
N = 7
str = "abbaeae"
Output
4
Explanation:
All palindrome substring are : "bb" , "abba" ,"aea",
"eae"

Expected Time Complexity : O(|S|2)
Expected Auxilliary Space : O(|S|2)

Constraints:

2<=|S|<=500

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.

Count Palindrome Sub-Strings of a String

Output Window