Class Solution

  • All Implemented Interfaces:

    
    public final class Solution
    
                        

    3210 - Find the Encrypted String\.

    Easy

    You are given a string s and an integer k. Encrypt the string using the following algorithm:

    • For each character c in s, replace c with the <code>k<sup>th</sup></code> character after c in the string (in a cyclic manner).

    Return the encrypted string.

    Example 1:

    Input: s = "dart", k = 3

    Output: "tdar"

    Explanation:

    • For i = 0, the 3<sup>rd</sup> character after 'd' is 't'.

    • For i = 1, the 3<sup>rd</sup> character after 'a' is 'd'.

    • For i = 2, the 3<sup>rd</sup> character after 'r' is 'a'.

    • For i = 3, the 3<sup>rd</sup> 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 &lt;= s.length &lt;= 100

    • <code>1 <= k <= 10<sup>4</sup></code>

    • s consists only of lowercase English letters.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
      Solution()
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      final String getEncryptedString(String s, Integer k)
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait