All prompts are owned by LeetCode. To view the prompt, click the title link above.
First completed : June 29, 2024
Last updated : June 29, 2024
Related Topics : String
Acceptance Rate : 81.73 %
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)