当前位置:网站首页>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;
}
};
边栏推荐
- Wan Weiwei, a researcher from Osaka University, Japan, introduced the rapid integration method and application of robot based on WRS system
- Opencv daily function structure analysis and shape descriptor (7) finding polygon (contour) / rotating rectangle intersection
- Earthly 容器镜像构建工具 —— 筑梦之路
- Distributed | how to make "secret calls" with dble
- China chip Unicorn Corporation
- A tip to read on Medium for free
- What is the future development trend of Business Intelligence BI
- 【牛客】把字符串转换成整数
- Increase insert speed
- MySQL | view notes on Master Kong MySQL from introduction to advanced
猜你喜欢
随机推荐
数据中台:数据中台技术架构详解
用VNC Viewer的方式远程连接无需显示屏的树莓派
Introduction to data platform
GradScaler MaxClipGradScaler
2022春招面试总结
What is SRE? A detailed explanation of SRE operation and maintenance system
Analyze the meaning of Internet advertising terms CPM, CPC, CPA, CPS, CPL and CPR
Fast and slow pointer series
所说的Get post:请求的区别,你真的知道了吗??????
Telnet port login method with user name for liunx server
One article explains in detail | those things about growth
What is the future development trend of Business Intelligence BI
Numpy 中的方法汇总
leetcode——错误的集合
数据中台:中台架构及概述
什么是图神经网络?图神经网络有什么用?
Background management of uniapp hot update
"Unusual proxy initial value setting is not supported", causes and Solutions
Matlab camera calibrator camera calibration
数组相向指针系列









