Anagram substring indices
Given two strings s and p, return a list (ascending) of all start indices in s where a substring is an anagram (permutation) of p. 1 <= len(p) <= len(s) <= 100000, lowercase letters. Example: s='cbaebabacd', p='abc' -> [0,6].
Implement
find_anagrams(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 24 min
solution.py
InputExpectedGot
["cbaebabacd","abc"][0,6]not run yetsample