2. Reverse String
EasyTwo Pointers Verified judge
Given a single word s, return the string reversed. Try to do it in-place with O(1) extra memory using two pointers.
Example 1
Input
hello
Output
olleh
Example 2
Input
OpenAI
Output
IAnepO
Input format
Input: one line containing the word `s`. Output: the reversed word.
Constraints
- 1 ≤ s.length ≤ 10^5
- s contains printable ASCII characters (no spaces)
Verified judge
Expected output
olleh