You are given a string s and an array of strings words of the same length. Return all starting indices of substring(s) in s that is a concatenation of each word in wordsexactly once, in any order, and without any intervening characters.
Input: s ="barfoothefoobarman", words =["foo","bar"]Output: [0,9]Explanation: Substrings starting at index 0 and 9 are "barfoo" and "foobar" respectively.The output order does not matter, returning [9,0]is fine too.
Example 2:
1
2
Input: s ="wordgoodgoodgoodbestword", words =["word","good","best","word"]Output: []
Example 3:
1
2
Input: s ="barfoofoobarthefoobarman", words =["bar","foo","the"]Output: [6,9,12]
To find all the starting indices of substring(s) that are concatenations of all words in the input array:
Calculate the length of each word and the total length of the concatenated substring.
Use sliding window technique to traverse through the string s.
For each window, check if the concatenation of words is valid by maintaining a frequency count of words and matching it with the words in the current window.