FastPrepDNA Sequence Match
Problems/DNA Sequence Match

DNA Sequence Match

SpaceX logoSpaceX● MediumFULLTIMEOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a SpaceX online assessment. The report describes matching DNA sequences from a file. It does not give the file layout, the exact matching rule, the output format, examples or limits. Our version is about 66% the same as the reported idea.

DNA Sequence Match

A text file is represented by lines, where every line is a DNA string. Find every exact occurrence of target in the file.

Return the matches in line order and then start-index order. Encode each match as lineIndex:startIndex, using zero-based indices. Overlapping matches count separately. Return an empty array when no match exists.

Function

findDnaSequenceMatches(lines: String[], target: String) → String[]

Examples

Example 1

lines = ["AACGTA","CGTA"]target = "CGT"return = ["0:2","1:0"]

CGT begins at index 2 in the first line and index 0 in the second line.

Example 2

lines = ["AAAAA"]target = "AAA"return = ["0:0","0:1","0:2"]

The three occurrences overlap, and all of them are returned.

Example 3

lines = ["ACGT"]target = "TT"return = []

The target does not occur in the file.

Constraints

  • 1 ≤ lines.length ≤ 10,000
  • 0 ≤ lines[i].length and the sum of all line lengths is at most 200,000.
  • 1 ≤ target.length ≤ 100,000
  • Every line and target contains only A, C, G, and T.

More SpaceX interview questions

  • Starlink Beam PlannerOA · PHONE SCREEN · Seen Nov 2026
  • Timestamped Telemetry Stream DifferencesPHONE SCREEN · Seen Sep 2026
  • Number of IslandsPHONE SCREEN · Seen Aug 2026
  • Number of Islands IIPHONE SCREEN · Seen Aug 2026
  • Button Combination DetectorPHONE SCREEN · Seen Feb 2026
  • Rocket Component CostONSITE INTERVIEW · Seen Aug 2025
  • Pressure Chamber Linear InterpolationPHONE SCREEN · Seen Jun 2025
  • Speed to Pressure LookupPHONE SCREEN · Seen Mar 2025
  • Simplified Time-Based Key-Value StorePHONE SCREEN · Seen Nov 2023
  • Find the Duplicate NumberONSITE INTERVIEW · Seen Jan 2021

Similar questions at other companies

  • Parse Router LogsIntuit · OAIntuit interview questions
  • Simplify a Quadratic ExpressionOpenAI · OAOpenAI interview questions
  • Correct Apartment Bedroom CountsRamp · OARamp interview questions
  • Remove CSS Comments and Find Hex ColorsAdobe · OAAdobe interview questions
  • Create New VersionCisco · OACisco interview questions
  • Order LayoutAmazon · OA
  • Validate and Parse HTTP RequestsIBM · OAIBM interview questions
  • Convert Backticked Identifiers to Camel CaseZipRecruiter · OAZipRecruiter interview questions
  • Simplified XML ValidatorAirbnb · OAAirbnb interview questions
  • Hidden ArtifactsIMC Trading · OAIMC Trading interview questions

Interview reports that mention this question

  • 2013–2026 SpaceX Full-Time OA / Interviews: 45 Experiences (Part 2 :)
  • SpaceX Software Engineer OA and Interviews: 27 Experiences
  • SpaceX Software Engineer Six-Hour Take-Home: 1 Experience

SpaceX interview experiences

  • SpaceX Full-Time Interview Cycle and Delayed Decision
  • SpaceX Experienced Engineer Full-Time Thirteen-Interview Process
  • SpaceX Senior Hardware Engineer Full-Time Interrupted Onsite
All SpaceX interview questionsSee SpaceX hiring insights
Saved
class Solution {
    public String[] findDnaSequenceMatches(String[] lines, String target) {
        // Write your code here.
    }

}
Checking account…