Dsa
Sliding Window
Medium
K-Character Anagram Substring
Given a string `s` and an integer `k`, determine if there exists any substring of length `k` which is an anagram of another substring of the same length.
Input:
- The first line contains an integer n (1 ≤ n ≤ 10^5), the length of the string.
- The second line contains the string `s`, consisting of lowercase English letters.
- The third line contains an integer k (1 ≤ k ≤ n).
Output:
- Print 'True' if at least one anagrammatic substring of length `k` exists; otherwise print 'False'.
Example:
Input:
8
ababaaba
3
Output:
True
Key concepts
sliding_windowstringsanagrams
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