🍊Let Code-逆文字列(Reverse String)


Reverse String


文字列を裏返す。入力値はアルファベット順に与えられます。文字列をin placeに反転して返さない


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 <= 2 * 105
  • s  consists only of printable ASCII characters.
  • KEY1: in-place reverse

    ソリューション

    class Solution(object):
        def reverseString(self, s):
            s.reverse()