Pattern occurrences
Given a text string t and a non-empty pattern p, return a list (ascending) of all starting indices where p occurs in t. Occurrences may overlap. 1 <= len(p) <= len(t) <= 100000, lowercase letters. Example: p='aa', t='aaaa' -> [0,1,2].
Implement
find_all_occurrences(t: str, p: str) → list[int]Examples
in
["aaaa","aa"]out[0,1,2]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
["aaaa","aa"][0,1,2]not run yetsample