Intuition
- Build a set to store all the words
- Iterate the slice index from 0 to end.
- If all the words in the substring are appear once in the words, add the index to the result.
solution
|
|
problem
WA.
reason
The words may be duplicate, so set is not proper to save the words.
modification
Change set to map
|
|
promote
There’s a better solution using two pointer(sliding window), it’s similar with the Minimum Window Substring problem. Update after solve that one.