Easy

Quiz

#344 Reverse String

APPROACH

Reverse the character array s in-place, swapping characters from both ends toward the center, using only O(1) additional memory.

Example 1:

Input: s = ["h","e","l","l","o"]
Output: ["o","l","l","e","h"]

Example 2:

Input: s = ["H","a","n","n","a","h"]
Output: ["h","a","n","n","a","H"]
1 of 4
1:00

What is the optimal approach for this problem?