見出し画像

ほぼ日刊競プロ leetcode 344. Reverse String

344. Reverse String

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.

考えたこと

元々の配列をひっくり返せばOK

class Solution:
   def reverseString(self, s: List[str]) -> None:
       """
       Do not return anything, modify s in-place instead.
       """
       s.reverse()

いいなと思ったら応援しよう!