Facebook Pixel

You are on level: Student

0%
Expand section
Expand section
Expand section
Expand section
Expand section
Expand section
Expand section
Expand section
Expand section
Expand section
Expand section

Palindrome Counting

Count the number of palindromes that exist in a particular string. Duplicates are allowed so long as they cover distinct intervals of the string. Empty strings do not count towards this total.

Example 1:

Input: abab

Output: 6

Explanation:

The following intervals are palindromes(0-indexed), [0,0],[1,1],[2,2],[3,3],[0,2],[1,3]

Try it yourself

Solution

Invest in Yourself
Your new job is waiting. 83% of people that complete the program get a job offer. Unlock unlimited access to all content and features.
Go Pro