ง่าย 0 ข้อที่แก้แล้ว อัตราผ่าน 0%

DNA to RNA Transcription

Build an RNA string by replacing every DNA character with its partner.

โจทย์

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 กรุณาทำตามคำชี้แจงและข้อจำกัดด้านบน

เรียนรู้จากคนอื่น

แนวทางจากชุมชน

ยังไม่มีวิธีทำที่เผยแพร่ ลองแก้โจทย์นี้เพื่อแชร์วิธีแรก