EasyAcceptance: 72.8%
4. Reverse String
Description
Write a function that reverses a string. The input string is given as an array of characters s. You must do this by modifying the input array in-place with O(1) extra memory.
Examples
Example 1
Input: s = ["h","e","l","l","o"]
Output: ["o","l","l","e","h"]
Explanation: Reverse the array in-place.
Constraints
- •1 <= s.length <= 10^5
- •s[i] is a printable ascii character.
Topics
StringTwo Pointers
💡 Tip: Start with a brute force solution and then optimize. Don't worry about performance initially.
Want more challenges?
Explore more coding challenges and improve your problem-solving skills
Browse All Challenges →