Dsa
Sliding Window
Medium
K-Length Distinct Palindromic Substrings
Given a string s and an integer k, find the number of distinct palindromic substrings of length k.
Example:
Input:
"ababa", 3
Output:
2
(Note: The distinct palindromic substrings of length 3 are "aba" and "bab".)
Key concepts
sliding_windowpalindromesubstring
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