Reverse a String

EASY

Write a Python function that takes a string s as input and returns the string reversed.

Examples:

Example 1:

Input: s = "hello"
Output: "olleh"

Example 2:

Input: s = "Python"
Output: "nohtyP"

Constraints:

  • 0 <= len(s) <= 5 * 104
  • s consists of printable ASCII characters.

Function Signature (Python):

class Solution:
    def reverseString(self, s: str) -> str:
        # Your code here
        pass

 

Nerchuko Academy · Free DS Interview Prep