FunctionRacerProblemsRace

Words Glued Together

HardHash mapsPython, JavaScript, TypeScript, Java, C++

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

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More Hash maps problems