1844. Replace All Digits with Characters
https://leetcode.com/problems/replace-all-digits-with-characters
Description
You are given a 0-indexed string s
that has lowercase English letters in its even indices and digits in its odd indices.
There is a function shift(c, x)
, where c
is a character and x
is a digit, that returns the xth
character after c
.
For example,
shift('a', 5) = 'f'
andshift('x', 0) = 'x'
.
For every odd index i
, you want to replace the digit s[i]
with shift(s[i-1], s[i])
.
Return s
after replacing all digits. It is guaranteed that shift(s[i-1], s[i])
will never exceed 'z'
.
Example 1:
Example 2:
Constraints:
1 <= s.length <= 100
s
consists only of lowercase English letters and digits.shift(s[i-1], s[i]) <= 'z'
for all odd indicesi
.
ac
Last updated