Problem statement

https://binarysearch.com/problems/Bulk-Shift-Letters/

Solution

Equal to Leetcode 0848 Shifting Letters.

Complexity

It is O(n) for time and space.

Code

class Solution:
    def solve(self, S, shifts):
        SH = list(accumulate(shifts[::-1]))[::-1]
        return "".join(chr((ord(s) - 97 + SH[i]) % 26 + 97) for i, s in enumerate(S))