Goldman SachsOA #5
Palindrome Counter
Estimated MediumJudge-ready
Topics (AI-labelled)PalindromesStrings
Given a string consisting only of lowercase English letters, count the occurrences of palindromic substrings in it. Identical content at different positions is counted separately.
Input
A single line containing the string s, of length 1..5000, consisting only of lowercase English letters.
Output
Output the number of palindromic substring occurrences.
Example 1
Input:
tacocat
Output:
10
Example 2
Input:
aaa
Output:
6
Example 3
Input:
abccba
Output:
9
Editorial
Loading solution…