🍊Leet Code - 문자열 뒤집기(Reverse String)

Hansol Kang·2021년 8월 22일
0

알고리즘

목록 보기
2/2
post-thumbnail

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()
profile
놀면 뭐하니 정리해

0개의 댓글