![]() |
VOOZH | about |
Given a word pattern and a string text consisting of lowercase characters, find the count of substrings in text which are anagrams of the pattern.
Examples:
Input : text = "forxxorfxdofr", pattern = "for"
Output : 3
Explanation : Anagrams present are for, orf and ofr. Each appears in the text once and hence the count is 3.Input : text = "aabaabaa", pattern = "aaba"
Output : 4
Explanation : Anagrams present are aaba and abaa. Each appears twice in the text and hence the count is 4.
Table of Content
Traverse the string and check every substring whose length equals the pattern. For each substring, verify whether it contains all the characters of the word.
3
3