QUICK START:HTMLCSSJavaScriptTypeScriptPythonSQLReactNext.jsNode.jsDSASystem DesignDevOpsCybersecurityAI / ML
AlgorithmBeginner Solved

Reverse String In-Place (Two Pointers)

Write a function that reverses an array of characters in-place using O(1) extra memory.

Requirements:

  • Do not allocate extra space for another array.
  • You must modify the input array in-place with O(1) extra memory.
Sample Input:
s = ['h', 'e', 'l', 'l', 'o']
Sample Output:
['o', 'l', 'l', 'e', 'h']
javascript• Solution Editor
EXECUTION CONSOLE Tests Passed (+75 XP)
Click “Run & Test Code” to execute your solution against test cases.