AlgoLounge

String Reversal

easy

Given a string, return it with all characters in reverse order.

Examples

Example 1

Input:  "hello"
Output: "olleh"

Example 2

Input:  "abc"
Output: "cba"

Example 3

Input:  ""
Output: ""

Constraints

  • String can be empty
  • Preserve all characters including spaces
TypeScript
Loading editor…
List of test cases (10)
Case 1
s = "hello"
Case 2
s = "abc"
Case 3
s = ""
Case 4
s = "a"
Case 5
s = "hello world"
Case 6
s = "12345"
Case 7
s = "racecar"
Case 8
s = "Python"
Case 9
s = " spaces "
Case 10
s = "!@#"