String Reversal
Reversing a string appears in many simple algorithms, such as palindrome checks and text processing. Write a function reverse_string that returns a new string where all characters of s appear in reverse order. The characters themselves stay the same; only their order changes. An empty string should remain empty.
Примеры
Ввод
"hello"Вывод
"olleh"Ввод
"Rosetta"Вывод
"attesoR"Ввод
""Вывод
""Нужно реализовать
def reverse_string(s: str) -> str:
Теги
stringstwo-pointers
Idħol biex tara l-istorja tas-sottomissjonijiet
IdħolIdħol biex tuża l-Mentor tal-AI
IdħolVisible tests
1
Input
"hello"Expected
"olleh"2
Input
"Rosetta"Expected
"attesoR"3
Input
""Expected
""4
Input
"a"Expected
"a"5
Input
"abcba"Expected
"abcba"6
Input
"12345"Expected
"54321"Focus radio
Paused · SomaFM · Fluid