問題
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.
例
例 1
入力:
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.
例 2
入力:
dna = ""
期待される出力:
expected = ""
入力:
std::string dna = "";
期待される出力:
std::string expected = "";
入力:
string dna = "";
期待される出力:
string expected = "";
解説
There are no characters to replace, so the result is empty.
参考資料
この課題はCodeUtility用に調整されています。上記の説明と制約に従ってください。