Description
Solutions
Submission
Rolling String (For Data Science 🍇)
🤘 INTERN

The Caesar Cipher involves shifting all characters in a string by a number to produce new string. For instance, with a shift of 1 right, the string 'abcz' becomes 'bcda'. Note that the rotation is circular, so z --> 1 = a. This challenge involves a modification in that substring within the string are shifted inside of the whole string.

Consider a string s, composed of English lowercase letters ascii[a-z]. There are two kinds of operations you can perform on s:

1. Roll Forward (right): i j R.

Every character in the substring s[i], s[i + 1],..., s[j-1], s[j] will roll forward and be replaced with its next sequential alphabetical character (the next character after z is a). For example: a -> b, m -> n, z -> a.

Roll Backward (left): i j L.

Every character in the substring s[i], s[i + 1],..., s[j-1], s[j] will roll backward and be replaced with its preceding alphabetical character (the character preceding a is z). For example: y <- z, m <- n, z <- a.

Example 1:

Input:  s = "abc", operations = ["0 0 L", "2 2 L", "0 2 R"]
Output: acc
Explanation:
After performing operation 0 0 L on "abc", s = zbc After performing operation 2 2 L on "zbc", s = zbb After performing operation 0 2 R on "zbb", s = acc We then return the final value of s, which is "acc".
Constraints:
  • 1 <= |s| <= 150
  • 1 <= n <= 100
  • 0 <= i <= j < |s|
  • ch ε {L, R}
Testcase

Result
Case 1

input:

output: