Problem · String
Rolling String
Learn this problemProblem statement
Given a lowercase English string s and a list of operations, apply the operations in order and return the final string.
Each operation has the form "i j D", where i and j are 0-based inclusive indices and D is one of:
R: roll every character ins[i..j]one position forward in the alphabet, withzbecominga.L: roll every character ins[i..j]one position backward in the alphabet, withabecomingz.
Function
rollingString(s: String, operations: String[]) → StringExamples
Example 1
s = "abc"operations = ["0 0 L", "2 2 L", "0 2 R"]return = "acc"0 0 Lchangesabctozbc.2 2 Lchanges it tozbb.0 2 Rchanges it toacc.
Therefore the final string is acc.
Constraints
1 ≤ s.length ≤ 1501 ≤ operations.length ≤ 100scontains only lowercase English letters.- Every operation has valid indices
0 ≤ i ≤ j < s.lengthand directionLorR.
More IBM problems
- Parent Process NumberOA · Seen Jul 2026
- Request Retry CountOA · Seen Jul 2026
- Count Strictly Increasing Subsequences of Length 3OA · Seen Jul 2026
- Maximum Requests in a Time WindowOA · Seen Jul 2026
- Query Type Frequency WindowOA · Seen Jul 2026
- Minimum Number of Non-Empty Disjoint SegmentsOA · Seen Jul 2026
- Spam Text ClassificationOA · Seen Jul 2026
- Count Ideal NumbersOA · Seen Jun 2026