Anagram substring indices
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.
Implement
find_anagram_indices(s: str, p: str) → list[int]Examples
in
["cbaebabacd","abc"]out[0,6]What a strong answer looks like
State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
0:00 of about 25 min
solution.py
InputExpectedGot
["cbaebabacd","abc"][0,6]not run yetsample