You are given a lowercase string s and operations in shifts. Each operation [start, end, direction] changes every character in the inclusive range from start to end by one alphabet position.
A direction of 1 moves forward, with z wrapping to a. A direction of 0 moves backward, with a wrapping to z. Apply all operations and return the final string.
Example 1:
Input: s = "az"
shifts = [[0,1,1]]
Output: "ba"Explanation: Shift both characters forward once: a becomes b, and z wraps around to a. The result is "ba".
Example 2:
Input: s = "aaa"
shifts = [[0,2,0],[1,1,1]]
Output: "zaz"Explanation: The first operation shifts all three a characters backward, producing "zzz". The second shifts only the middle character forward, so the final string is "zaz".
Example 3:
Input: s = "xyz"
shifts = [[0,1,1],[1,2,0]]
Output: "yyy"Explanation: The first operation changes "xyz" to "yzz". The second moves the last two characters backward, resulting in "yyy". The shifts cancel at the overlapping middle position.
Constraints:
1 <= s.length <= 500001 <= shifts.length <= 50000scontains only lowercase English letters.- Each shift contains exactly three integers:
[start, end, direction]. 0 <= start <= end < s.lengthdirectionis either0or1.