Because all the words are the same length, we can use hash map to check for substring from index i to index i +word length * words number.
Then we can traverse all the i index.
However, we can use sliding window to reduce creation of hash map.
For each start, there are 3 situations:
the current word is not in the word list, then the whole substring is invalid. so the window will start from the next word.
the current word is in the words list, but it appears more times than in the words list. So in this case we start remove words from window in the front, until the other current word is reached and removed.
the words are all matched, so we removed the first word from the window.