Given a string and a list of words of the same length, find all start indices in the string of concatenations of each word.
For example, for string
"barfoomanthefoobar" and words
"bar"] the corresponding indices are
The input consists of two lines.
The first line is the string where you will search for concatenations
The second line is the list of words.
Words are separated by a single space.
Output consists of a single line.
The line consists of all the indices separated by a single space.
Order of the indices does not matter.
Here is a Ruby implementation.
Want to read more?
I love to explain and answer questions on programming problems.
I publish a new programming problem and its solution every month.
Did I mention that I love to answer questions?
If you would like to get the latest problem + solution, subscribe to the newsletter
or subscribe via RSS.
You can also follow me on