Pattern matching with mismatches
Given a text string and a shorter pattern string (both lowercase), find every starting index in the text where the pattern matches with at most k character mismatches (Hamming distance <= k over the window). Return the list of matching start indices in increasing order. The text length is up to a few thousand characters and 0 <= k <= len(pattern).
Implement
fuzzy_match(text: str, pattern: str, k: int) → list[int]Examples
in
["abcde","axc",1]out[0]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
["abcde","axc",1][0]not run yetsample