Dsa
Recursion
Easy
Counting Palindromic Substrings
Write a program that counts how many distinct palindromic substrings are in a given string using recursion. A palindrome is a string that reads the same backward as forward. We consider substrings to be distinct based on their starting and ending indices.
Input Format:
- A single line containing the input string.
Output Format:
- An integer representing the count of distinct palindromic substrings.
Example:
Input:
ababa
Output:
5
Key concepts
recursionstring manipulationpalindrome
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