Given a string S and a word C, return the count of the occurrences of anagrams of the word in the text. Both string and word are in lowercase letter
belongs to collection: Interview C++ coding problems/challenges | String
All Answers
total answers (1)
Algorithm:
So the idea is pretty simple. What we are doing is to slide the window and check for anagrams. Window is nothing but the substring being extracted every time. Window length is equal to the word length.
To check anagrams
So this basically means, we are constructing a container using the elements of string a. Then we are destructing the map to form string b. If such formation is possible they strings are anagrams of each other.
C++ implementation:
Output
need an explanation for this answer? contact us directly to get an explanation for this answer