3. Reverse a String
EasyStrings~5 min
Write a function that takes a string and returns a new string with the characters in reverse order.
For example, "hello" becomes "olleh".
Examples
Example 1
- Input:
- str = "hello"
- Output:
- "olleh"
Example 2
- Input:
- str = "RunScript"
- Output:
- "tpircSnuR"
Constraints
0 <= str.length <= 1000The string may contain spaces and punctuation.