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 ["foo",
"bar"] the corresponding indices are [0,12].
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, the kind you find in coding interviews.
I publish a new programming problem and its solution every Sunday.
Did I mention that I love to answer questions?