Practice Reverse String
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
Write a function that reverses a string. The input string is given as an array of characters s. You must do this by modifying the input array in-place with O(1) extra memory.
Source: Reverse String on LeetCode. Use the original task for its coding environment and submissions.
Examples
# 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"]
Constraints
1 <= s.length <= 10^5
s[i] is a printable ascii character.
Related LeetCode Problems
Practice more problems similar to Reverse String.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.