Đề bài
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.
Ràng buộc
0 ≤ DNA length ≤ 100,000. Characters are uppercase A, C, G, or T.
Ví dụ
Đầu vào:
dna = "ACGT"
Kết quả mong đợi:
expected = "UGCA"
Đầu vào:
std::string dna = "ACGT";
Kết quả mong đợi:
std::string expected = "UGCA";
Đầu vào:
string dna = "ACGT";
Kết quả mong đợi:
string expected = "UGCA";
Giải thích
A becomes U, C becomes G, G becomes C, and T becomes A, giving UGCA.
Đầu vào:
dna = ""
Kết quả mong đợi:
expected = ""
Đầu vào:
std::string dna = "";
Kết quả mong đợi:
std::string expected = "";
Đầu vào:
string dna = "";
Kết quả mong đợi:
string expected = "";
Giải thích
There are no characters to replace, so the result is empty.
Tham khảo
Thử thách này đã được điều chỉnh cho CodeUtility. Hãy làm theo đề bài và các ràng buộc ở trên.