Dsa
Strings
Warm-up
Palindromic Substring Counter
Create a function to count how many palindromic substrings a given string contains. A substring is palindromic if it reads the same backward as forward.
Input:
- A single line containing the string.
Output:
- The number of palindromic substrings in the string.
Example:
Input:
"abba"
Output:
"6" (the substrings are "a", "b", "bb", "abba", "a", "a")
Key concepts
stringssubstringspalindrome
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now