'''
string = "aaa"
After Shifting the first 1 letter by 1 = "baa"
After shifting the first 2 letters by 2 = "dca"
After shifting the first 3 letters 3 = "gfd"
result = "gfd"
'''
def shifLetters(s, shifts) :
size = len(shifts)
lst = []
i = size - 1
while (i >= 0) :
if (i + 1 < size) :
shifts[i] += shifts[i + 1]
shifts[i] = shifts[i] % 26
asciicode = ord(s[i]) - ord('a')
asciicode = asciicode + shifts[i]
if (asciicode > 25) :
asciicode = asciicode - 26
lst.append(chr(ord('a') + asciicode))
i -= 1
lst.reverse()
return ''.join(lst)
s = "aaa"
shifts = [1, 2, 3]
s = shifLetters(s, shifts)
print(s)
'''
run:
gfd
'''