Anagram Substring Search

Given a string A and a string B.

Find and return the starting indices of the substrings of A which matches any of the anagrams of B.

Note: An anagram is a play on words created by rearranging the letters of the original word to make a new word or phrase



Input Format

The arguments given are string A and string B.

Output Format

Return the starting indices of the substrings of A which matches any of the anagrams of B.

Constraints

1 <= length of the string A,B <= 100000
length of string A > length of string B
'a' < = A[i] ,B[i] < ='z'

For Example

Input 1:
    A = "BACDGABCDA"
    B = "ABCD"
Output 1:
    [0, 5, 6]

Input 2:
    A = "AAABABAA"
    B = "AABA"
Output 2:
    [0, 1, 4]
NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a doubt? Checkout Sample Codes for more details.
Start solving Anagram Substring Search on Interview Code Editor
Sign Up
to access hints and editorial solutions for Anagram Substring Search

Discussion


Loading...
Click here to start solving coding interview questions