Anagram substring indices

Write codeMedium25 min

Your task

Given a lowercase text string s and a lowercase pattern p, return the start indices of all substrings of s that are anagrams of p (same multiset of characters), in increasing order. For s='cbaebabacd', p='abc' return [0,6]. Lengths up to a few thousand.

Examples

find_anagram_indices(s: str, p: str) -> list[int]
Example 1
Inputfind_anagram_indices("cbaebabacd", "abc")
Output[0, 6]