Watch 10 video solutions for Find the Encrypted String, a easy level problem involving String. This walkthrough by NeetCode has 333,550 views views. Want to try solving it yourself? Practice on FleetCode or read the detailed text solution.
You are given a string s and an integer k. Encrypt the string using the following algorithm:
c in s, replace c with the kth character after c in the string (in a cyclic manner).Return the encrypted string.
Example 1:
Input: s = "dart", k = 3
Output: "tdar"
Explanation:
i = 0, the 3rd character after 'd' is 't'.i = 1, the 3rd character after 'a' is 'd'.i = 2, the 3rd character after 'r' is 'a'.i = 3, the 3rd character after 't' is 'r'.Example 2:
Input: s = "aaa", k = 1
Output: "aaa"
Explanation:
As all the characters are the same, the encrypted string will also be the same.
Constraints:
1 <= s.length <= 1001 <= k <= 104s consists only of lowercase English letters.