Code RoomAnagram substring search
MediumPrep Room Coding #1634

Anagram substring search

CodingAlgorithms & data structuresMid–Senior~25 min

Given strings s and p, return the start indices of every substring of s that is an anagram of p.

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 25 min
InputExpectedGot
["cbaebabacd","abc"][0,6]not run yetsample