MEDIUMasked at 4 companies

Repeated DNA Sequences

A medium-tier problem at 51% community acceptance, tagged with Hash Table, String, Bit Manipulation. Reported in interviews at Grammarly and 3 others.

Founder's read

Repeated DNA Sequences is a medium-difficulty string problem that shows up in assessments at Google, Tesla, LinkedIn, and Grammarly. You're given a DNA string and need to find all 10-letter substrings that appear more than once. The naive approach is slow. The trick is rolling hash or bit manipulation to scan the string in one pass without recalculating hashes for overlapping windows. This problem separates candidates who know when to apply sliding window from those who brute-force. If you hit this live and blank on the optimization, StealthCoder surfaces a working solution invisible to the proctor.

Companies asking
4
Difficulty
MEDIUM
Acceptance
51%

Companies that ask "Repeated DNA Sequences"

If this hits your live OA

Repeated DNA Sequences is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Built by an Amazon engineer who realized the OA tests how well you memorized 200 problems, not how well you code.

Get StealthCoder
What this means

The problem looks simple: find duplicate substrings. But comparing every 10-letter window naively is O(n) windows times O(10) comparison, which flails on large inputs. The real solution uses rolling hash or bit encoding. With rolling hash, you compute the hash of the first window, then slide right one character at a time, subtracting the leftmost character's contribution and adding the new rightmost one. That's O(n) time, O(k) space where k is the number of unique hashes. Bit manipulation is faster: treat each DNA letter (A, C, G, T) as 2 bits, pack 10 letters into a 20-bit integer, and shift left-right to roll. Most candidates see 'find duplicates' and reach for a hash set without the rolling part, then timeout. StealthCoder is your insurance for the live OA when the rolling hash pattern doesn't click.

Pattern tags

The honest play

You know the problem. Make sure you actually pass it.

Repeated DNA Sequences recycles across companies for a reason. It's medium-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Built by an Amazon engineer who realized the OA tests how well you memorized 200 problems, not how well you code. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Repeated DNA Sequences interview FAQ

Is this problem actually asked at FAANG?+

Yes. Google, Tesla, LinkedIn, and Grammarly have all reportedly asked it. It's a classic string and hash table intersection. Companies use it to test whether you know when brute-force fails and can optimize with hashing or bit tricks.

What's the trick I'm missing if my solution times out?+

You're likely recalculating the hash or comparing all 10 characters for each window. Rolling hash or bit manipulation eliminates that. Update the hash in O(1) per step instead of O(10). The trick is the 'rolling' part, not the hash itself.

Should I use rolling hash or bit manipulation?+

Both work. Bit manipulation is faster on this problem because you're only dealing with 4 DNA letters, so a 20-bit integer fits. Rolling hash is more general if the problem changes. Either shows you understand the pattern, so pick the one you can code faster on exam day.

How does this relate to the other hash table and sliding window topics?+

This problem bundles all four: sliding window (10-letter windows), hash table (store seen hashes), hash function (rolling hash or bit encoding), and bit manipulation (optional optimization). It's a real-world interview problem that tests multiple skills at once.

What's the acceptance rate, and does that mean it's hard?+

Acceptance rate is around 51 percent. That's moderate, not brutal. Most failures come from timeout, not wrong logic. If you know the rolling hash pattern, you solve it quickly. If not, you'll hit the wall and run out of time.

Want the actual problem statement? View "Repeated DNA Sequences" on LeetCode →

Frequency and company-tag data sourced from public community-maintained interview-report repos. Problem, description, and trademark © LeetCode. StealthCoder is not affiliated with LeetCode.