调试中...
调试中...
题目描述
题目描述
题解
题解
提交记录
提交记录
代码
代码
测试用例
测试用例
测试结果
测试结果
简单
相关标签
相关企业
提示

给你一个下标从 0 开始的字符串 s ,它的 偶数 下标处为小写英文字母,奇数 下标处为数字。

定义一个函数 shift(c, x) ,其中 c 是一个字符且 x 是一个数字,函数返回字母表中 c 后面第 x 个字符。

  • 比方说,shift('a', 5) = 'f' 和 shift('x', 0) = 'x' 。

对于每个 奇数 下标 i ,你需要将数字 s[i] 用 shift(s[i-1], s[i]) 替换。

请你替换所有数字以后,将字符串 s 返回。题目 保证 shift(s[i-1], s[i]) 不会超过 'z' 。

 

示例 1:

输入:s = "a1c1e1"
输出:"abcdef"
解释:数字被替换结果如下:
- s[1] -> shift('a',1) = 'b'
- s[3] -> shift('c',1) = 'd'
- s[5] -> shift('e',1) = 'f'

示例 2:

输入:s = "a1b2c3d4e"
输出:"abbdcfdhe"
解释:数字被替换结果如下:
- s[1] -> shift('a',1) = 'b'
- s[3] -> shift('b',2) = 'd'
- s[5] -> shift('c',3) = 'f'
- s[7] -> shift('d',4) = 'h'

 

提示:

  • 1 <= s.length <= 100
  • s 只包含小写英文字母和数字。
  • 对所有 奇数 下标处的 i ,满足 shift(s[i-1], s[i]) <= 'z' 。
通过次数
17.4K
提交次数
21.9K
通过率
79.6%

相关标签

相关企业

提示 1
We just need to replace every even positioned character with the character s[i] positions ahead of the character preceding it

提示 2
Get the position of the preceeding character in alphabet then advance it s[i] positions and get the character at that position

相似题目

评论 (0)

贡献者
© 2025 领扣网络(上海)有限公司
0 人在线
行 1,列 1
运行和提交代码需要登录
s =
"a1c1e1"
Source