Problème
Build an RNA string by replacing every DNA character with its partner. Use this complete mapping: A → U, C → G, G → C, T → A. Preserve the original order. No biology knowledge is needed.
Implement dna_to_rna(dna).
Input
dna: The DNA string to transform.
Output
Return the transformed string. Empty input returns an empty string.
Contraintes
0 ≤ DNA length ≤ 100,000. Characters are uppercase A, C, G, or T.
Exemples
Entrée :
dna = "ACGT"
Sortie attendue :
expected = "UGCA"
Entrée :
std::string dna = "ACGT";
Sortie attendue :
std::string expected = "UGCA";
Entrée :
string dna = "ACGT";
Sortie attendue :
string expected = "UGCA";
Explication
A becomes U, C becomes G, G becomes C, and T becomes A, giving UGCA.
Entrée :
dna = ""
Sortie attendue :
expected = ""
Entrée :
std::string dna = "";
Sortie attendue :
std::string expected = "";
Entrée :
string dna = "";
Sortie attendue :
string expected = "";
Explication
There are no characters to replace, so the result is empty.
Références
Ce défi a été adapté pour CodeUtility. Suivez l'énoncé et les contraintes ci-dessus.