Submissions disabled: This deployment is running in read-only mode for safety. Code execution is not available here.
← Back to all problems
Easy

Reverse String

Updated Jan 31, 2026

Problem

Write a function that reverses a string.

The input string is given as a list of characters. You must do this by modifying the input list in-place with O(1) extra memory.

Constraints

1 <= s.length <= 10^5
s[i] is a printable ASCII character.

Examples

Example 1

Input: s = ["h","e","l","l","o"]
Output: ["o","l","l","e","h"]
The string "hello" reversed is "olleh".

Example 2

Input: s = ["H","a","n","n","a","h"]
Output: ["h","a","n","n","a","H"]

Function Signature

def reverseString(self, s: list[str]) -> None

How to Submit

Implement a Solution class with a reverseString method.

Your method will be called with the input parameters and should return the answer.