Significance:
Finding over-represented k-mers is the computational basis of **de novo motif discovery** — e.g., locating a DnaA box (bacterial origin of replication) or a transcription factor binding motif without prior knowledge of what it looks like. It's also the conceptual seed for k-mer-based genome assemblers (see Problem 18) and k-mer-based sequence classifiers like Kraken.
Statement
Given a DNA string `s` and an integer `k`, find the **most frequent** k-mer(s) — substrings of length `k` — in `s`. Overlapping occurrences count separately. If multiple k-mers tie for the highest frequency, return **all** of them, space-separated, sorted lexicographically.
Sample Input
ACGTTGCATGTCGCATGATGCATGAGAGCT
4
Sample Output
CATG GCAT
Constraints
- `1 ≤ length(s) ≤ 500`, `1 ≤ k ≤ length(s)`
My Notes
Log in to save personal notes.
Console output will appear here when you click Run Code or Submit...