#C8660. Count Distinct Anagram Substrings
Count Distinct Anagram Substrings
Count Distinct Anagram Substrings
You are given two strings: a text string and a pattern string. Your task is to count the number of distinct substrings in the text that are anagrams of the pattern.
A substring of text is defined as a contiguous sequence of characters. Two substrings are considered different if their sequence of characters is different, even if they are anagrams. For example, if the text is "cbaebabacd"
and the pattern is "abc"
, there are exactly 2 distinct substrings ("cba" and "bac") that are anagrams of the pattern.
Note: If the length of the pattern \(m\) is greater than the length of the text \(n\), the result is 0.
inputFormat
The input consists of two lines read from stdin:
- The first line contains the text string.
- The second line contains the pattern string.
Both strings will consist of printable characters without extra whitespaces.
outputFormat
Output a single integer to stdout representing the count of distinct substrings in the text that are anagrams of the pattern.
## samplecbaebabacd
abc
2
</p>