Question bank › Strings
Dsa Strings Medium

DNA Assembler Chain

You are given a sequence of DNA fragments. You must assemble them into a single string by merging them in the order provided. For each pair of consecutive fragments (S_i and S_{i+1}), find the longest suffix of S_i that is exactly equal to a prefix of S_{i+1}. If an overlap exists, merge S_{i+1} onto the current result by overlapping these characters. If no overlap exists (overlap length is 0), join the two strings using a '#' character. Example: Input: 'ATGC GCTA TACC' 1. 'ATGC' and 'GCTA' overlap at 'GC' (length 2). Result: 'ATGCTA'. 2. 'ATGCTA' and 'TACC' overlap at 'TA' (length 2). Result: 'ATGCTACC'. Output: 'ATGCTACC'

Key concepts

stringsslicingoverlap

Practise this out loud — free

Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.

🎙 Practise this question now
Part of InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.