Problem
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.
Einschränkungen
0 ≤ DNA length ≤ 100,000. Characters are uppercase A, C, G, or T.
Beispiele
Eingabe:
dna = "ACGT"
Erwartete Ausgabe:
expected = "UGCA"
Eingabe:
std::string dna = "ACGT";
Erwartete Ausgabe:
std::string expected = "UGCA";
Eingabe:
string dna = "ACGT";
Erwartete Ausgabe:
string expected = "UGCA";
Erläuterung
A becomes U, C becomes G, G becomes C, and T becomes A, giving UGCA.
Eingabe:
dna = ""
Erwartete Ausgabe:
expected = ""
Eingabe:
std::string dna = "";
Erwartete Ausgabe:
std::string expected = "";
Eingabe:
string dna = "";
Erwartete Ausgabe:
string expected = "";
Erläuterung
There are no characters to replace, so the result is empty.
Referenzen
Diese Aufgabe wurde für CodeUtility angepasst. Beachte die oben genannten Vorgaben und Einschränkungen.