121. Reverse String

Easy · String

Write a function that reverses a string. The input is a single string, and you should return the reversed version of that string.

This is a fundamental string manipulation problem that tests your understanding of string indexing and iteration.

Examples

Example 1
Input: "hello"
Output: "olleh"
Explanation: The string "hello" reversed character-by-character becomes "olleh".
Example 2
Input: "a"
Output: "a"
Explanation: A single character string reversed is itself.

Constraints