Words Glued Together
All the words in words have the same length. Return every index of text where a stretch begins that is all the words glued together, each used exactly once, in any order. List the indexes from small to large.
Example 1
text "catdogcatbirddog"
words ["dog","cat"]
returns [0,3]
"catdog" starts at 0 and "dogcat" at 3. At 6, "catbir" is not made of the two words.
Example 2
text "aaaa"
words ["a","a"]
returns [0,1,2]
Every pair of neighbors is "a" then "a".
Constraints
1 <= len(text) <= 801 <= len(words) <= 6- Each word has 1 to 4 lowercase letters
texthas lowercase letters only
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More Hash maps problems
- Already Seen FlagsBeginner
- Best Score per NameBeginner
- Check if the Sentence Is PangramBeginner
- Count Elements With a NextBeginner
- Difference of Two ArraysBeginner
- First Repeated WordBeginner
- Is IsogramBeginner
- Jewels and StonesBeginner