Trains the technique from
LeetCode 2381Shifting Letters IIThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
A tape of lowercase letters reads tape. Each entry rolls[i] = [from, to, forward] names a stretch of the tape from position from to position to, both ends included, and says which way every letter in that stretch rolls: 1 rolls each letter one step forward through the alphabet and 0 rolls it one step back.
The alphabet wraps round, so rolling 'z' forward gives 'a' and rolling 'a' back gives 'z'.
Apply every roll in the list and return the tape afterwards.
Example 1
One roll forward over the whole tape moves each letter one step on.
Example 2
Rolling both letters forward turns the a into b and wraps the z round to a.
Example 3
Only the first letter is in the stretch, and rolling a backwards wraps it round to z.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def shifting_letters(tape: str, rolls: list[list[int]]) -> str:public String shiftingLetters(String tape, int[][] rolls)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.