Search⌘ K
AI Features

Solution: Reverse String

Solution: Reverse String gives you a character array and asks you to reverse its contents in place, changing the original array while using only constant extra memory.

Statement

You are given a character array, s, representing a string. Write a function that reverses the array in-place.

  • The reversal must be done by modifying the original array directly.

  • You cannot use extra memory beyond a constant amount O(1)O(1) ...