totalShifts
to 0 to keep track of the accumulated shifts.shifts
array in reverse order.
shifts[i]
, add it to totalShifts
.totalShifts
modulo 26 (the number of letters in the alphabet).i
in the string s
by the effective shift amount.s
.s
after all shifts have been applied.