Anagram Windows
Count the substrings of T that are anagrams (permutations) of P.
Input: two lines: the text T, then the pattern P.
Output: the number of anagram occurrences.
Constraints:
- 1 ≤ |T| ≤ 105
- 1 ≤ |P| ≤ |T|
- lowercase letters
Sample Tests
Input 1
abab ab
Output 1
3
Input 2
aaa aa
Output 2
2
Discussion (opens after you solve — no spoilers before)
No comments yet.