Skip to content

Latest commit

 

History

History
55 lines (41 loc) · 1.19 KB

_344. Reverse String.md

File metadata and controls

55 lines (41 loc) · 1.19 KB

All prompts are owned by LeetCode. To view the prompt, click the title link above.

Back to top


First completed : June 01, 2024

Last updated : July 01, 2024


Related Topics : Two Pointers, String

Acceptance Rate : 78.652 %


Solutions

Java

// 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;
        }
    }
}

Python

# 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]