Approximate Motif Matching (Motif with Mismatches)

Intermediate Approximate Matching Hamming Distance Motif Search
Significance:
Biology is noisy — sequencing errors, natural polymorphism, and imperfect regulatory motifs mean exact string matching (Problem 6) is often too strict for real use. Approximate matching, allowing up to `d` mismatches, is exactly how tools like Bowtie/BWA locate a read's true genomic origin despite sequencing errors, and how transcription-factor binding sites are located even though they tolerate some sequence degeneracy.
Statement

Given a DNA string `s`, a motif `t`, and an integer `d`, find all starting positions (1-based) in `s` where a substring of length `len(t)` matches `t` with **at most `d` mismatches** (measured as Hamming distance).

Sample Input
s = GATATATGCATATACTTATA
t = ATAT
d = 1
Sample Output
2 4 10 12 16
Constraints

- `1 ≤ length(s) ≤ 1000`, `1 ≤ length(t) ≤ length(s)`, `0 ≤ d ≤ length(t)`


My Notes
Log in to save personal notes.
Console output will appear here when you click Run Code or Submit...
Enter DNA / RNA / Protein test string
Next Problem
Protein Molecular Weight