Problem
You are given a string s and a list words whose strings all have the same length. A chain is any string you can make by gluing together every word in words exactly once, in any order (a word listed twice must be used twice). Return the starting index of every substring of `s` that is a chain, in any order.
Example 1
- Input
- s = "dogcatcatdog", words = ["cat", "dog"]
- Output
- [0, 6]
- Why
- "dogcat", "catdog"
Example 2
- Input
- s = "aaaa", words = ["aa", "aa"]
- Output
- [0]
Example 3
- Input
- s = "xyzab", words = ["ab", "cd"]
- Output
- []
Constraints
1 <= s.length <= 10^41 <= words.length <= 50001 <= words[i].length <= 30s and every word contain only lowercase English letters.