Solve the substring with concatenation of all words problem, O(S * wordLength).