Repeated DNA Sequences
Updated
Problem statement
Given a DNA string s containing only A, C, G and T, return every distinct contiguous substring of exactly 10 characters that appears at least twice.
- Occurrences at different starting positions count separately, even when they overlap.
- Return each repeated substring exactly once, in ascending lexicographic order using
A < C < G < T. - Match the characters exactly. Reversed strings and reverse complements are not equivalent.
- If no substring repeats, including when
s.length < 10, return an empty array.
Interview context
This is the standard repeated DNA sequence exercise, with follow-ups on corner cases, time complexity and space complexity.
Explain the time and auxiliary space of your solution, including how many different windows it stores and any work used to order the result.
Function
findRepeatedDnaSequences(s: String) → List<String>Examples
Example 1
s = "ACGTACGTACGTACGT"return = ["ACGTACGTAC","CGTACGTACG","GTACGTACGT"]The windows starting at 0, 1 and 2 reappear at 4, 5 and 6. The window at 3 appears once.
Example 2
s = "TTTTTTTTTTT"return = ["TTTTTTTTTT"]The two length-10 windows begin at 0 and 1. They overlap and have identical text, so the result contains that text once.
Example 3
s = "ACGT"return = []The string is shorter than 10, so it has no complete window.
Constraints
0 <= s.length <= 2000.- Every character of
sis one ofA,C,GorT.
More NVIDIA Phone Screen questions
- Network Layer Execution OrderPHONE SCREEN · Seen Nov 2026
- Paged KV Cache AccessPHONE SCREEN · Seen Nov 2026
- Sliding Window Attention over a KV CachePHONE SCREEN · Seen Nov 2026
- Summarize Server Healthcheck LogsPHONE SCREEN · Seen Oct 2026
- Hash Partition OffsetsPHONE SCREEN · Seen Oct 2026
- Filter Paginated Medical RecordsPHONE SCREEN · Seen Oct 2026
- Least Frequently Used CachePHONE SCREEN · Seen Oct 2026
- Parallel String Counts with a Custom Hash TablePHONE SCREEN · Seen Oct 2026
- Simulate a Reference-Counted Smart PointerPHONE SCREEN · Seen Aug 2026
- Streaming Top-K Frequent ElementsPHONE SCREEN · Seen Aug 2026
Similar questions at other companies
- Longest Substring Without Repeating CharactersAngel One · PHONE SCREEN
- Longest Substring Without Repeating CharactersNykaa · PHONE SCREENNykaa interview questions
- Longest Substring Without Repeating CharactersIBM · PHONE SCREENIBM interview questions
- Longest Substring Without Repeating CharactersTikTok · PHONE SCREENTikTok interview questions
- Find Word-Multiset WindowsAmazon · PHONE SCREEN
- Find the First Contiguous HaikuFaire · PHONE SCREEN
- Longest Substring Without Repeating CharactersCapgemini · PHONE SCREENCapgemini interview questions
- Longest Substring Without Repeating CharactersWex · PHONE SCREEN
- Minimum Window of Required WordsSalesforce · PHONE SCREENSalesforce interview questions
- Longest Substring Without Repeating CharactersRedNote · PHONE SCREEN