Count Occurences of Anagrams
Easy Accuracy: 36.06% Submissions: 546 Points: 2

Given a word pat and a text txt. Return the count of the occurences of anagrams of the word in the text.

Example 1:

txt = forxxorfxdofr
pat = for
Output: 3
Explanation: for, orf and ofr appears
in the txt, hence answer is 3.

Example 2:

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 to print answer or take inputs.

Expected Time Complexity: O(N)
Expected Auxiliary Space: O(26) or O(256)

1 <= |pat| <= |txt| <= 105
Both string contains lowercase english letters.


to report an issue on this page.


We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?


All Submissions

My Submissions:

Login to access your submissions.

Output Window