Problem · String
Reverse A String
Learn this problemProblem statement
You are given a string s consisting of printable ASCII characters.
Return a new string whose characters are the characters of s in reverse order.
The empty string reverses to the empty string.
Function
reverseString(s: String) → StringExamples
Example 1
s = "hello"return = "olleh"Reading hello from right to left produces olleh.
Example 2
s = "a"return = "a"A single character is already reversed.
Constraints
0 <= s.length <= 10^5.scontains only printable ASCII characters.