Question bank › Strings
Dsa Strings Easy

Palindrome Substrings

Given a string, count the number of distinct substrings that are palindromes. A substring is defined as a contiguous sequence of characters within the string. A palindrome is a string that reads the same forwards and backwards. Input: A single line containing the input string. The string will be non-empty and contains only lowercase English letters. Output: A single integer: the count of distinct palindromic substrings. Example: Input: abba Output: 6 Explanation: The distinct palindromic substrings are: "a", "b", "bb", "abba", "bab", and "a".

Key concepts

stringspalindromessubstring

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
Part of InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.