Dsa
Recursion
Hard
The DNA Helix Expansion
A DNA sequence $S_n$ grows by doubling and mutating. $S_0 = "A"$. To form $S_n$, take $S_{n-1}$ and append a 'shifted' version of $S_{n-1}$, where $A \to T, T \to C, C \to G, G \to A$. Thus, $S_1 = "AT"$, $S_2 = "ATTC"$, $S_3 = "ATTCTCGG"$. Given $N$ and $K$, find the $K$-th character (0-indexed) of $S_N$. Constraints: $N \le 60, K < 2^N$.
Key concepts
recursionstring manipulationbase conversion
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