Practice Shifting Letters II
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
You are given a string s of lowercase English letters and a 2D integer array shifts where shifts[i] = [starti, endi, directioni]. For every i, shift the characters in s from the index starti to the index endi (inclusive) forward if directioni = 1, or shift the characters backward if directioni = 0. Shifting a character forward means replacing it with the next letter in the alphabet (wrapping around so that 'z' becomes 'a'). Similarly, shifting a character backward means replacing it with the previous letter in the alphabet (wrapping around so that 'a' becomes 'z'). Return the final string after all such shifts to s are applied.
Source: Shifting Letters II on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
s = "abc", shifts = [[0,1,0],[1,2,1],[0,2,1]]
"ace"
# Example 2
s = "dztz", shifts = [[0,0,0],[1,1,1]]
"catz"
Constraints
Related LeetCode Problems
Practice more problems similar to Shifting Letters II.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.