a TLE solution for substring with concatenation of all words.