Practice/Google/Leetcode 30. Substring with Concatenation of All Words
CodingOptional
You are given a string s and an array words where each word in the array has the same length. Your task is to identify all starting positions in s where a substring can be formed by concatenating each word from words exactly once, in any order.
Return a list of all such starting indices. The indices can be returned in any order.
words must appear exactly once in the valid substringwords have identical lengths and words[i] consist of lowercase English letterswords have the same lengthExample 1:
` Input: s = "barfoothefoobarman", words = ["foo", "bar"] Output: [0, 9] Explanation:
Example 2:
Input: s = "wordgoodgoodgoodbestword", words = ["word", "good", "best", "word"] Output: [] Explanation: No position in s contains a valid concatenation of all four words exactly once each.
Example 3:
` Input: s = "barfoofoobarthefoobarman", words = ["bar", "foo", "foo"] Output: [0, 6] Explanation: