The Question
CodingSubstring with Concatenation of All Words
Given a string
s and an array of strings words where all strings in words are of the same length, find all starting indices of substring(s) in s that represent a concatenation of every string in words exactly once, in any order, without any intervening characters.
Example:
Input: s = "barfoothefoobarman", words = ["foo","bar"]
Output: [0,9]
Explanation: Substrings starting at index 0 and 9 are "barfoo" and "foobar" respectively, which are permutations of ["foo","bar"].
Constraints:
- 1 <= s.length <= 10,000
- 1 <= words.length <= 5,000
- 1 <= words[i].length <= 30
- s and words[i] consist of lowercase English letters.Java
Sliding Window
HashMap