find_the_encrypted_string
1# @leet start 2class Solution: 3 def getEncryptedString(self, s: str, k: int) -> str: 4 """ 5 This class returns the string, where for a string `s`, and an integer `k`, 6 for each character `c` in `s`, replacing `c` with the `kth` character after `c` in the string. 7 It does this literally. 8 """ 9 return ''.join(s[(i + k) % len(s)] for i in range(len((s)))) 10 11# @leet end 12sol = Solution() 13def test(): 14 assert(sol.getEncryptedString('dart', 3) == 'tdar') 15 assert(sol.getEncryptedString('aaa', 1) == 'aaa')
class
Solution:
3class Solution: 4 def getEncryptedString(self, s: str, k: int) -> str: 5 """ 6 This class returns the string, where for a string `s`, and an integer `k`, 7 for each character `c` in `s`, replacing `c` with the `kth` character after `c` in the string. 8 It does this literally. 9 """ 10 return ''.join(s[(i + k) % len(s)] for i in range(len((s))))
def
getEncryptedString(self, s: str, k: int) -> str:
4 def getEncryptedString(self, s: str, k: int) -> str: 5 """ 6 This class returns the string, where for a string `s`, and an integer `k`, 7 for each character `c` in `s`, replacing `c` with the `kth` character after `c` in the string. 8 It does this literally. 9 """ 10 return ''.join(s[(i + k) % len(s)] for i in range(len((s))))
This class returns the string, where for a string s, and an integer k,
for each character c in s, replacing c with the kth character after c in the string.
It does this literally.
sol =
<Solution object>
def
test():