This problem can be solved in O(NK).
Assuming the length of each word is K, then no matter how long the string is, a match can be found by starting at position (0 to K-1) and advance by units of K.
For each of the K starting positions, we can find all matches in a single pass by maintaining 2 cursors, one pointing at the start of current cancatenation, and the other at the end. And we take the next K chars and compare it to words: