Given a string S, the task is to check if S contains a pair of substrings of length K which are anagrams of each other and doesn’t contain the character X in them. If no such substring exists, print -1.
Examples:
Input:_ S = “geeksforgeeks”, X = ‘f’, K = 5_
Output:_ geeks geeks_
Explanation:
Substrings “geeks” and “geeks” are anagrams of each other and does not contain ‘f’.
_Input: _S = “rotator”, X = ‘a’, K = 3
_Output: _rot tor
Explanation:
Substrings “rot” and “tor” are anagrams of each other and does not contain ‘a’.
#competitive programming #hash #searching #strings #anagram #frequency-counting #java-hashmap #substring