Find the K-th Character in String Game II

Solution Code
class Solution:
    def kthCharacter(self, k: int, operations: List[int]) -> str:
        shifts = 0
        
        for i in range(len(operations) - 1, -1, -1):
            length_before = 2 ** i
            if k > length_before:
                k -= length_before
                shifts += operations[i]
                
        return chr((shifts % 26) + 97)

Time Complexity

O(log k)

Space Complexity

O(1)