Find All Anagrams in a String
Given two strings s and p, return an array of all the start indices of p's anagrams in s. You may return the answer in any order.
Example 1
Input
s = "cbaebabacd", p = "abc"Output
[0,6]The substrings starting at indices 0 and 6 are
"cba" and "bac", both of which are anagrams of "abc".Example 2
Input
s = "abab", p = "ab"Output
[0,1,2]The substrings starting at indices 0, 1, and 2 are
"ab", "ba", and "ab", all of which are anagrams of "ab".Constraints
- 1 <= s.length, p.length <= 3 * 10^4
sandpconsist of lowercase English letters.