Dsa
Two Pointers
Medium
Find All Anagrams
You are given two strings 's' and 'p'. Return the starting indices of all anagrams of 'p' in 's'. An anagram is a permutation of the letters of a string. The output should be a space-separated string of starting indices.
Input Format:
- A single line containing strings 's' and 'p' separated by a space.
Output Format:
- A space-separated string of starting indices.
Example:
Input:
cbaebabacd abcd
Output:
0 6
Key concepts
two_pointerssliding_windowstring_manipulation
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