You get two strings, s and p. An anagram of p uses exactly the same letters as p, each one the same number of times, in any order. Find every place in s where a run of p.length consecutive characters is an anagram of p, and return the index where each such run starts.
The runs may overlap. If p is longer than s, nothing fits and the answer is empty. You may return the indices in any order.
tae (index 0), eat (index 2) and eta (index 6) each rearrange into eat. A run such as atb holds a b, so it doesn't count.
Every two-letter run is xy or yx, so all four starting positions count, even though the runs share letters.
p has three letters and s only two, so no run of s is long enough.
Constraints
1 <= s.length <= 3 * 10⁴1 <= p.length <= 3 * 10⁴s and p contain only lowercase English letters.Two runs of the same length are anagrams exactly when every letter appears the same number of times in both, so compare letter counts instead of sorting.