Skip to content

Latest commit

 

History

History
40 lines (26 loc) · 925 Bytes

_848. Shifting Letters.md

File metadata and controls

40 lines (26 loc) · 925 Bytes

All prompts are owned by LeetCode. To view the prompt, click the title link above.

Back to top


First completed : June 29, 2024

Last updated : June 29, 2024


Related Topics : Array, String, Prefix Sum

Acceptance Rate : 44.815 %


Solutions

Python

class Solution:
    def shiftingLetters(self, s: str, shifts: List[int]) -> str:
        output = []

        for i in range(len(shifts) - 2, -1, -1) :
            shifts[i] += shifts[i + 1]

        for i, c in enumerate(s) :
            output.append(chr((ord(c) - ord('a') + shifts[i]) % 26 + ord('a')))

        return ''.join(output)