#2EasyStrings & Two Pointers· Opposite Direction Pointers

Reverse String In-Place

Write a function that reverses an array of characters in-place with O(1) extra memory. You must do this by modifying the input array in-place with O(1) auxiliary memory.

Input format

s: Array of characters

Output format

None (modify array in-place)

Examples

Input: s = ["h","e","l","l","o"]
Output: ["o","l","l","e","h"]
The input array is inverted in-place.

Constraints

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

Study first

  • #two-pointers
  • #strings
  • #programming-fundamentals