โจทย์
ดูฉบับแปลReverse text so the last character comes first.
Implement reverse_string(text).
Input
text: The text to reverse.
Output
Return the reversed text.
เงื่อนไข
0 ≤ length ≤ 10,000
ตัวอย่าง
ตัวอย่างที่ 1
อินพุต:
text = "hello"
ผลลัพธ์ที่คาดหวัง:
expected = "olleh"
อินพุต:
std::string text = "hello";
ผลลัพธ์ที่คาดหวัง:
std::string expected = "olleh";
อินพุต:
string text = "hello";
ผลลัพธ์ที่คาดหวัง:
string expected = "olleh";
คำอธิบาย
h-e-l-l-o read backwards is "olleh".
ตัวอย่างที่ 2
อินพุต:
text = "a"
ผลลัพธ์ที่คาดหวัง:
expected = "a"
อินพุต:
std::string text = "a";
ผลลัพธ์ที่คาดหวัง:
std::string expected = "a";
อินพุต:
string text = "a";
ผลลัพธ์ที่คาดหวัง:
string expected = "a";
คำอธิบาย
A single character reversed is itself.
แหล่งอ้างอิง
โจทย์นี้ปรับให้เหมาะกับ CodeUtility กรุณาทำตามคำชี้แจงและข้อจำกัดด้านบน