Skip to main content
CodeOath
← All problems

Problem

Reverse a String

Easy
  • strings

Return str with its characters in the opposite order.

Example 1
Input
str = "hello"
Output
"olleh"
Explanation

the last letter comes first and the first letter comes last.

Example 2
Input
str = ""
Output
""
Explanation

an empty string has nothing to reorder.

Constraints:

  • 0 <= str.length <= 10^4

Tab indents. Press Esc, then Tab to leave the editor.

Run your code to see every test here. Nothing is submitted or recorded.