Description
Given a string s and an integer array shifts, shift s[i] by the sum of shifts[i...n-1]. Return the final string.
Examples
Input:
s = "abc", shifts = [3,5,9]Output:
"rpl"Explanation:
Apply shifts.
Input:
s = "hello", shifts = [1, 1, 1, 1, 1]Output:
mjqqtExplanation:
Each position i is shifted by the total of shifts[i] through shifts[end]. Position 0 shifts by 1+1+1+1+1=5, position 1 by 1+1+1+1=4, etc. Applying these cumulative shifts to "hello" produces "mjqqt".
Input:
s = "z", shifts = [25]Output:
yExplanation:
Single character case with wrap-around. Shifting the first 1 letter ('z') by 25 positions. Since 'z' is the last letter of the alphabet, shifting by 25 wraps around: 'z' + 25 = 'z' + 25 mod 26 = 'z' - 1 = 'y'.
Constraints
- •
1 ≤ s.length ≤ 10⁵