본문 바로가기
python-algorithm

leetcode 3210. Find the Encrypted String

by 무적김두칠 2024. 9. 23.

https://leetcode.com/problems/find-the-encrypted-string/description/

1
2
3
4
5
6
7
8
class Solution:
    def getEncryptedString(self, s: str, k: int-> str:
        answer = ""
 
        for i in range(len(s)):
            answer += s[(i+k)%len(s)]
        
        return answer
cs

문자열 s 를 rotate 하는 느낌으로 구현

반응형

댓글