Write a function that reverses a character array in-place. You must do this with O(1) extra memory.
Classic two-pointer swap: pointers at both ends, swap and move inward.
- lo=0, hi=s.length-1.
- While lo
- Time Complexity: O(N)
- Space Complexity: O(1)
Write a function that reverses a character array in-place. You must do this with O(1) extra memory.
Classic two-pointer swap: pointers at both ends, swap and move inward.