#17Assembly Line Inspector
A factory has an automated production line that generates a long sequence of component codes represented by a string s. The quality inspector is given a list of words, where each word represents the code of a required component. All component codes have the same length. A complete batch is a continuous section of the production line that contains every required component code exactly once, placed next to each other in any order. For example, if: words = ["ax", "by", "cz"] Then the following are valid complete batches: axbycz, axczby, byaxcz, byczax, czaxby, czbyax However: aybxcz is not valid because it cannot be divided into the given component codes.
Your task is to find all starting indices in s where a complete batch begins. Return the indices in any order.
Examples
Example 1
Input: s = "partboltgearpartbolt"
words = ["part", "bolt"]
Output: [0, 12]
Explanation: At index 0, "partbolt" contains "part" and "bolt" exactly once. At index 12, "partbolt" again forms a complete batch.
Example 2
Input: s = "catdogdogcatdogcat"
words = ["cat", "dog"]
Output: [0, 6, 9, 12]
Explanation: Index 0 → "catdog" Index 6 → "dogcat" Index 9 → "catdog" Index 12 → "dogcat"
Example 3
Input: s = "axbyczaxczby"
words = ["ax", "by", "cz"]
Output: [0, 9]
Explanation: Index 0 → "axbycz" → contains all three component codes. Index 6 → "axczby" → contains the same codes in a different order.
Constraints
- 1 <= s.length <= 10^4
- 1 <= words.length <= 5000
- 1 <= words[i].length <= 30
- s and words[i] contain lowercase English letters.
