3210. Find the Encrypted String
3210. Find the Encrypted String
Description
You are given a string s
and an integer k
. Encrypt the string using the following algorithm:
- For each character
c
ins
, replacec
with thek^th
character afterc
in the string (in a cyclic manner).
Return the encrypted string.
Example 1:
1 | Input: s = "dart", k = 3 |
Explanation:
- For
i = 0
, the 3^rd character after'd'
is't'
. - For
i = 1
, the 3^rd character after'a'
is'd'
. - For
i = 2
, the 3^rd character after'r'
is'a'
. - For
i = 3
, the 3^rd character after't'
is'r'
.
Example 2:
1 | Input: s = "aaa", k = 1 |
Constraints:
1 <= s.length <= 100
1 <= k <= 10^4
s
consists only of lowercase English letters.
Hints/Notes
- Weekly Contest 405
Solution
Language: C++
1 | class Solution { |