Given a word and a text, return the count of the occurences of anagrams of the word in the text(For eg: anagrams of word for are for, ofr, rof etc.))
Input : forxxorfxdofr for Output : 3 Explanation : Anagrams of the word for - for, orf, ofr appear in the text and hence the count is 3. Input : aabaabaa aaba Output : 4 Explanation : Anagrams of the word aaba - aaba, abaa each appear twice in the text and hence the count is 4.
A simple approach is to traverse from start of the string considering substrings of length equal to the length of the given word and then check if this substring has all the characters of word.
An Efficient Solution is to use count array to check for anagrams, we can construct current count window from previous window in O(1) time using sliding window concept.
- Count subsequences in first string which are anagrams of the second string
- Check if two strings are k-anagrams or not
- Project Idea | (A Game of Anagrams )
- Given a sequence of words, print all anagrams together using STL
- Given a sequence of words, print all anagrams together | Set 1
- Given a sequence of words, print all anagrams together | Set 2
- Check if all levels of two trees are anagrams or not
- Print anagrams together in Python using List and Dictionary
- Print all pairs of anagrams in a given array of strings
- Count pairs in an array such that LCM(arr[i], arr[j]) > min(arr[i],arr[j])
- Count of 'GFG' Subsequences in the given string
- Count characters with same neighbors
- Longest substring with count of 1s more than 0s
- Count of sub-strings that are divisible by K
- Count Distinct Subsequences