📊알고리즘, 문제풀이/📈문제풀이 (PS)

[알고리즘][Python] LeetCode 344 Reverse String 문제 풀이

Written by Donghak Park

문제 출처 : leetcode.com/problems/reverse-string/

 

Reverse String - LeetCode

Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.

leetcode.com


문제 해석 : 문자 배열을 뒤집어라

 

문제 풀이 : 다양한 방법으로 풀 수 있지만 가장 간단하게 built-in 함수를 이용했다.

 

가능한 다른 풀이 : index를 이용해서 직접 변경해 줄 수 있다. 

 


풀이 코드

class Solution:
    def reverseString(self, s) -> None:
        s.reverse()


if __name__=="__main__":
    solution = Solution()
    s = ["h","e","l","l","o"]
    solution.reverseString(s)
    print(s)

author : donghak park
contact : donghark03@naver.com

## 문제의 저작권은 LeetCode 사이트에 있습니다. 혹시 문제가 되는 부분이 있으면 연락 바랍니다.