Write a function that reverses a string. The input string is given as an array of characters s.
Example 1:
Input: s = ["h","e","l","l","o"]
Output: ["o","l","l","e","h"]
Example 2:
Input: s = ["H","a","n","n","a","h"]
Output: ["h","a","n","n","a","H"]
Constraints:
1 <= s.length <= 105
s[i] is a printable ascii character.
class Solution:
def reverseString(self, s: List[str]) -> None:
s.reverse()
Runtime(184ms), Memory(18.8MB)
[::-1]
을 사용하고 싶으면 s[:] = s[::-1]
제가 저 코드로 똑같이 세 번 정도 돌려봤는데 런타임이 215ms였다가 184ms였다가 263ms이었다가...
거꾸로 출력
.reverse()