Menu
CoddyTech

Reverse a String

You get a string s made of English letters and digits. Return a new string with the same characters in reverse order, so the last character comes first and the first comes last. Keep every character exactly as it is, including its case.

Function

reverseString(s: string) → string
sstring
the string to reverse
Returnsstring
the characters of s in reverse order

Constraints

  • 1 ≤ s.length ≤ 104
  • s contains only English letters (a to z, A to Z) and digits (0 to 9).

Examples

Input
s = "Coddy2026"
Output
"6202yddoC"
Explanation
Read Coddy2026 from its last character to its first: 6, 2, 0, 2, then y, d, d, o and finally the capital C.

lock icon+14 hidden tests on Submit

challenge icon

Follow-up

How would you reverse the order of the words in a sentence, turning hello big world into world big hello, while every word keeps its letters in order?

Reset code
def reverseString(s):
    # Write code here
Test cases

Case 1

Case 2

Case 3

Input

s = "Coddy2026"

Expected

"6202yddoC"