P16287 [GeeksforGeeks] Count occurences of anagrams5839
普及
题目描述

Given a word pat and a text txt. Return the count of the occurrences of anagrams of the word in the text.
Example 1:
Input:
txt = forxxorfxdofr
pat = for
Output: 3
Explanation: for, orf and ofr appears
in the txt, hence answer is 3.
Example 2:
Input:
txt = aabaabaa
pat = aaba
Output: 4
Explanation: aaba is present 4 times
in txt.
Your Task:
Complete the function search() which takes two strings pat, txt, as input parameters and returns an integer denoting the answer.
You don't need to print answer or take inputs.
Expected Time Complexity: O(N)
Expected Auxiliary Space: O(26) or O(256)
Constraints:
1 <= |pat| <= |txt| <= 10^{5}
Both strings contain lowercase English letters.

输入格式

见题面

输出格式

见题面

样例输入
txt = forxxorfxdofr pat = for
样例输出
3