Problem
Ask
Submissions

Problem: Reverse String

Medium
30 min
Explore how to reverse a character array in-place using the two pointers technique. Understand the constraints and implement a constant-memory solution to prepare for coding interviews.

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 <=<= s.length <=<= 10001000

  • Each s[i] is a printable ASCII character.

Problem
Ask
Submissions

Problem: Reverse String

Medium
30 min
Explore how to reverse a character array in-place using the two pointers technique. Understand the constraints and implement a constant-memory solution to prepare for coding interviews.

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 <=<= s.length <=<= 10001000

  • Each s[i] is a printable ASCII character.