Starting indices of the substrings in string

Given a string A and list of words B(words in B are of same length).

Find and return the starting indices of the substrings in string A, which contains all the words present in list B.

Note:

  1. The order of words of list B appearing inside string S does not matter.
  2. Words inside the list B can repeat.



Input Format

The arguments given are string A and a list of string B.

Output Format

Return the starting indices of the substrings in string A, which contains all the words present in list B.

Constraints

1 <= length of the string A <= 4000
1 <= total length of list B if all the words are concatenated <= 4000

For Example

Input 1:
    A = "barfoothefoobarman" 
    B = ["foo", "bar"] 
Output 1:
     [0, 9]

Input 2:
    S = "catbatatecatatebat"
    L = ["cat", "ate", "bat"] 
Output 2:
     [0, 3, 9]
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 Starting indices of the substrings in string on Interview Code Editor
Sign Up
to access hints and editorial solutions for Starting indices of the substrings in string

Discussion


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