Reverse String

Easy
String
Time Limit: 1000ms
Memory Limit: 128MB
Problem Description

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.

Constraints
  • 1 <= s.length <= 10^5
  • s[i] is a printable ASCII character
Input
{"s": ["h","e","l","l","o"]}
Output
["o","l","l","e","h"]
Loading...
Available Test Cases:5 test cases
Test Case 1Sample
Input: {"s": ["h","e","l","l","o"]}
Expected Output: ["o","l","l","e","h"]
Test Case 2Sample
Input: {"s": ["H","a","n","n","a","h"]}
Expected Output: ["h","a","n","n","a","H"]
Test Case 3Sample
Input: {"s": ["a"]}
Expected Output: ["a"]
Test Case 4Sample
Input: {"s": ["a","b","c","d","e","f"]}
Expected Output: ["f","e","d","c","b","a"]
⚠️ Hidden test case
Test Case 5Sample
Input: {"s": ["!","@","#","$","%"]}
Expected Output: ["%","$","#","@","!"]
⚠️ Hidden test case