当前位置:网站首页>1844. replace all numbers with characters
1844. replace all numbers with characters
2022-06-24 08:52:00 【Drag is me】
leetcode Force button to brush questions and punch in
1844. Replace all numbers with characters
describe : I'll give you a subscript from 0 Starting string s , its even numbers Small letters at the subscript , Odd number The subscript is a number .
Define a function shift(c, x) , among c Is a character and x It's a number , Function returns to the alphabet c Next x Characters .
For example ,shift(‘a’, 5) = ‘f’ and shift(‘x’, 0) = ‘x’ .
For each Odd number Subscript i , You need to put the numbers s[i] use shift(s[i-1], s[i]) Replace .
Please replace all the numbers later , The string s return . subject Guarantee shift(s[i-1], s[i]) Not more than ‘z’ .
Their thinking
1、 The topic looks complicated , In fact, the water forced .
Source code ##
class Solution {
public:
string replaceDigits(string s) {
for (int i = 0; i < s.size(); ++i) {
if (i % 2 == 1) {
s[i] = s[i - 1] + s[i] - '0';
}
}
return s;
}
};
边栏推荐
猜你喜欢

数据中台:中台架构及概述

A tip to read on Medium for free

基于QingCloud的 “房地一体” 云解决方案

MySQL | 存储《康师傅MySQL从入门到高级》笔记

JS to find and update the specified value in the object through the key
![[quantitative investment] discrete Fourier transform to calculate array period](/img/0d/aac02463ff403fb1ff871af5ff91fa.png)
[quantitative investment] discrete Fourier transform to calculate array period

liunx服务器 telnet 带用户名 端口登陆方法

什么是图神经网络?图神经网络有什么用?

【NOI模拟赛】给国与时光鸡(构造)

Distributed | how to make "secret calls" with dble
随机推荐
为什么ping不通,而traceroute却可以通
开源之夏中选名单已公示,基础软件领域成为今年的热门申请
【PyTorch基础教程30】DSSM双塔模型代码解析
[MySQL from introduction to mastery] [advanced part] (I) character set modification and underlying principle
Solving linear equations with MATLAB ax=b
One article explains in detail | those things about growth
何时使用RDD和DataFrame/DataSet
Numpy 中的方法汇总
用VNC Viewer的方式远程连接无需显示屏的树莓派
What is the future development trend of Business Intelligence BI
K8s deployment of highly available PostgreSQL Cluster -- the road to building a dream
【MySQL从入门到精通】【高级篇】(一)字符集的修改与底层原理
MySQL | store notes of Master Kong MySQL from introduction to advanced
Opencv daily function structure analysis and shape descriptor (7) finding polygon (contour) / rotating rectangle intersection
rpiplay实现树莓派AirPlay投屏器
How does the tunnel mobile inspection track robot monitor 24 hours to ensure the safety of tunnel construction?
Get screen width and height tool class
关于ETL看这篇文章就够了,三分钟让你明白什么是ETL
随笔-反思
It is enough to read this article about ETL. Three minutes will let you understand what ETL is