(Python, Java) 리트코드 - reverse string

[문제 링크]

Python 풀이

class Solution:
    def reverseString(self, s: List[str]) -> None:
        s.reverse()

Java 풀이

class Solution {
    public void reverseString(char[] s) {
        int left = 0;
        int right = s.length - 1;
        while (left < right) {
            char temp = s[left];
            s[left] = s[right];
            s[right] = temp;
            left++;
            right--;
        }
    }
}

© 2021. By Backtony