2381. Shifting Letters II

class Solution:
    def shiftingLetters(self, s: str, shifts: List[List[int]]) -> str:
        def moveForward(char, ops):
            aOrd = ord('a')
            return chr(aOrd + (ord(char) - aOrd + ops) % 26)

        operations = [0] * len(s)        
        for (start, end, direction) in shifts:
            if direction:
                operations[start] += 1
                if end + 1 < len(s):
                    operations[end + 1] -= 1
            else:
                operations[start] -= 1
                if end + 1 < len(s):
                    operations[end + 1] += 1


        result = list(s)
        x = 0
        for i in range(len(s)):
            x += operations[i]           
            result[i] = moveForward(s[i], x)

        return "".join(result)