Leaderboard
Showing:
Handle Score
@Ibrahim Nash 6420
@blackshadows 6380
@mb1973 5642
@Quandray 5233
@akhayrutdinov 5111
@saiujwal13083 4610
@sanjay05 3762
@kirtidee18 3673
@marius_valentin_dragoi 3522
@sushant_a 3459
@verma_ji 3413
Complete Leaderboard
Count Palindrome Sub-Strings of a String
Medium Accuracy: 58.02% Submissions: 243 Points: 4

Given a string, the task is to count all palindromic sub-strings present in it.

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

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