โจทย์
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.
เงื่อนไข
0 ≤ DNA length ≤ 100,000. Characters are uppercase A, C, G, or T.
ตัวอย่าง
อินพุต:
dna = "ACGT"
ผลลัพธ์ที่คาดหวัง:
expected = "UGCA"
อินพุต:
std::string dna = "ACGT";
ผลลัพธ์ที่คาดหวัง:
std::string expected = "UGCA";
อินพุต:
string dna = "ACGT";
ผลลัพธ์ที่คาดหวัง:
string expected = "UGCA";
คำอธิบาย
A becomes U, C becomes G, G becomes C, and T becomes A, giving UGCA.
อินพุต:
dna = ""
ผลลัพธ์ที่คาดหวัง:
expected = ""
อินพุต:
std::string dna = "";
ผลลัพธ์ที่คาดหวัง:
std::string expected = "";
อินพุต:
string dna = "";
ผลลัพธ์ที่คาดหวัง:
string expected = "";
คำอธิบาย
There are no characters to replace, so the result is empty.
แหล่งอ้างอิง
โจทย์นี้ปรับให้เหมาะกับ CodeUtility กรุณาทำตามคำชี้แจงและข้อจำกัดด้านบน