344. Reverse String
Easy
7.3K
1.1K

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.

 

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:

Accepted
2.1M
Submissions
2.7M
Acceptance Rate
76.9%

Seen this question in a real interview before?
1/4
Yes
No

Discussion (0)

Related Topics
Copyright ©️ 2023 LeetCode All rights reserved