344. Reverse String
All prompts are owned by LeetCode. To view the prompt, click the title link above.
First completed : June 01, 2024
Last updated : July 01, 2024
Related Topics : Two Pointers, String
Acceptance Rate : 78.652 %
// Daily question
class Solution {
public void reverseString(char[] s) {
for (int i = 0; i < s.length / 2; i++) {
char temp = s[i];
s[i] = s[s.length - i - 1];
s[s.length - i - 1] = temp;
}
}
}
# Daily question
class Solution:
def reverseString(self, s: List[str]) -> None:
"""
Do not return anything, modify s in-place instead.
"""
for i in range(0, len(s) // 2) :
s[i], s[len(s) - i - 1] = s[len(s) - i - 1], s[i]