Given two strings s and p, return all starting indices of substrings in s that are anagrams (permutations) of p.
s
: string
p
: string
i
such that
s[i : i+len(p)]
is an anagram of
p
.
s = "cbaebabacd"
,
p = "abc"
[0, 6]
s[0:3] = "cba"
is an anagram of
"abc"
s[6:9] = "bac"
is an anagram of
"abc"
1 <= |s|, |p| <= 3 * 10^4
(or similar interview-scale bounds).