题目:原题链接(简单)
标签:字符串
解法 | 时间复杂度 | 空间复杂度 | 执行用时 |
Ans 1 (Python) | 40ms (61.30%) | ||
Ans 2 (Python) | |||
Ans 3 (Python) |
解法一:
class Solution:
def replaceDigits(self, s: str) -> str:
lst = list(s)
size = len(lst)
for i in range(1, size, 2):
c, x = lst[i - 1], int(lst[i])
lst[i] = chr(((ord(c) - 97) + x) % 26 + 97)
return "".join(lst)