shiftAmounts with a length of len(s) + 1.[start, end, direction] in shifts:
a. If direction is 1 (forward), increment shiftAmounts[start] and decrement shiftAmounts[end + 1].
b. If direction is 0 (backward), decrement shiftAmounts[start] and increment shiftAmounts[end + 1].shiftAmounts to get the total shift amount for each character.s and for each character:
a. Calculate the new character index after applying the shift.
b. If the index is negative, add 26 until it is positive.
c. Convert the index back to a character and append it to the result string.