Search⌘ K
AI Features

Solution: Reverse String

Understand how to reverse a string given as a character array by applying the two pointers technique. Learn step-by-step how to swap characters from the ends inward, achieving an in-place reversal with constant space complexity and linear time complexity.

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).

Constraints

  • 11 ...