Skip to content

Latest commit

 

History

History
38 lines (27 loc) · 871 Bytes

_1844. Replace All Digits with Characters.md

File metadata and controls

38 lines (27 loc) · 871 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 : String

Acceptance Rate : 81.73 %


Solutions

Python

class Solution:
    def replaceDigits(self, s: str) -> str:
        output = []
        for i, c in enumerate(s) :
            if c.isalpha() :
                output.append(c)
            else :
                output.append(chr((int(c) + ord(s[i - 1]) - ord('a')) % 26 + ord('a')))

        return ''.join(output)